w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
pdp11_gr.vhd
Go to the documentation of this file.
1-- $Id: pdp11_gr.vhd 1310 2022-10-27 16:15:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2006-2022 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: pdp11_gr - syn
7-- Description: pdp11: general registers
8--
9-- Dependencies: memlib/ram_1swar_1ar_gen
10--
11-- Test bench: tb/tb_pdp11_core (implicit)
12-- Target Devices: generic
13-- Tool versions: ise 8.2-14.7; viv 2014.4-2022.1; ghdl 0.18-2.0.0
14-- Revision History:
15-- Date Rev Version Comment
16-- 2022-10-25 1309 1.0.3 rename _gpr -> _gr
17-- 2019-08-17 1203 1.0.2 fix for ghdl V0.36 -Whide warnings
18-- 2011-11-18 427 1.0.4 now numeric_std clean
19-- 2008-08-22 161 1.0.3 rename ubf_ -> ibf_; use iblib
20-- 2007-12-30 108 1.0.2 use ubf_byte[01]
21-- 2007-06-14 56 1.0.1 Use slvtypes.all
22-- 2007-05-12 26 1.0 Initial version
23------------------------------------------------------------------------------
24
25library ieee;
26use ieee.std_logic_1164.all;
27use ieee.numeric_std.all;
28
29use work.slvtypes.all;
30use work.memlib.all;
31use work.iblib.all;
32use work.pdp11.all;
33
34-- ----------------------------------------------------------------------------
35
36entity pdp11_gr is -- general registers
37 port (
38 CLK : in slbit; -- clock
39 DIN : in slv16; -- input data
40 ASRC : in slv3; -- source register number
41 ADST : in slv3; -- destination register number
42 MODE : in slv2; -- processor mode (k=>00,s=>01,u=>11)
43 RSET : in slbit; -- register set
44 WE : in slbit; -- write enable
45 BYTOP : in slbit; -- byte operation (write low byte only)
46 PCINC : in slbit; -- increment PC
47 DSRC : out slv16; -- source register data
48 DDST : out slv16; -- destination register data
49 PC : out slv16 -- current PC value
50 );
51end pdp11_gr;
52
53architecture syn of pdp11_gr is
54
55-- --------------------------------------
56-- the register map determines the internal register file storage address
57-- of a register. The mapping is
58-- ADDR RNUM SET MODE
59-- 0000 000 0 -- R0 set 0
60-- 0001 001 0 -- R1 set 0
61-- 0010 010 0 -- R2 set 0
62-- 0011 011 0 -- R3 set 0
63-- 0100 100 0 -- R4 set 0
64-- 0101 101 0 -- R5 set 0
65-- 0110 110 - 00 SP kernel mode
66-- 0111 110 - 01 SP supervisor mode
67-- 1000 000 1 -- R0 set 1
68-- 1001 001 1 -- R1 set 1
69-- 1010 010 1 -- R2 set 1
70-- 1011 011 1 -- R3 set 1
71-- 1100 100 1 -- R4 set 1
72-- 1101 101 1 -- R5 set 1
73-- 1110 111 - -- PC
74-- 1111 110 - 11 SP user mode
75
76 procedure do_regmap (
77 signal PRNUM : in slv3; -- register number
78 signal PMODE : in slv2; -- processor mode (k=>00,s=>01,u=>11)
79 signal PRSET : in slbit; -- register set
80 signal PADDR : out slv4 -- internal address in regfile
81 ) is
82 begin
83 if PRNUM = c_gr_pc then
84 PADDR <= "1110";
85 elsif PRNUM = c_gr_sp then
86 PADDR <= PMODE(1) & "11" & PMODE(0);
87 else
88 PADDR <= PRSET & PRNUM;
89 end if;
90 end procedure do_regmap;
91
92-- --------------------------------------
93
94 signal MASRC : slv4 := (others=>'0'); -- mapped source register address
95 signal MADST : slv4 := (others=>'0'); -- mapped destination register address
96 signal WE1 : slbit := '0'; -- write enable high byte
97 signal MEMSRC : slv16 := (others=>'0');-- source reg data from memory
98 signal MEMDST : slv16 := (others=>'0');-- destination reg data from memory
99 signal R_PC : slv16 := (others=>'0'); -- PC register
100
101begin
102
103 do_regmap(PRNUM => ASRC, PMODE => MODE, PRSET => RSET, PADDR => MASRC);
104 do_regmap(PRNUM => ADST, PMODE => MODE, PRSET => RSET, PADDR => MADST);
105
106 WE1 <= WE and not BYTOP;
107
108 GR_LOW : ram_1swar_1ar_gen
109 generic map (
110 AWIDTH => 4,
111 DWIDTH => 8)
112 port map (
113 CLK => CLK,
114 WE => WE,
115 ADDRA => MADST,
116 ADDRB => MASRC,
117 DI => DIN(ibf_byte0),
118 DOA => MEMDST(ibf_byte0),
119 DOB => MEMSRC(ibf_byte0));
120
121 GR_HIGH : ram_1swar_1ar_gen
122 generic map (
123 AWIDTH => 4,
124 DWIDTH => 8)
125 port map (
126 CLK => CLK,
127 WE => WE1,
128 ADDRA => MADST,
129 ADDRB => MASRC,
130 DI => DIN(ibf_byte1),
131 DOA => MEMDST(ibf_byte1),
132 DOB => MEMSRC(ibf_byte1));
133
134 proc_pc : process (CLK)
135 alias R_PC15 : slv15 is R_PC(15 downto 1); -- upper 15 bit of PC
136 begin
137 if rising_edge(CLK) then
138 if WE='1' and ADST=c_gr_pc then
139 R_PC(ibf_byte0) <= DIN(ibf_byte0);
140 if BYTOP = '0' then
141 R_PC(ibf_byte1) <= DIN(ibf_byte1);
142 end if;
143 elsif PCINC = '1' then
144 R_PC15 <= slv(unsigned(R_PC15) + 1);
145 end if;
146 end if;
147 end process proc_pc;
148
149 DSRC <= R_PC when ASRC=c_gr_pc else MEMSRC;
150 DDST <= R_PC when ADST=c_gr_pc else MEMDST;
151 PC <= R_PC;
152
153end syn;
Definition: iblib.vhd:33
slv4 :=( others => '0') MASRC
Definition: pdp11_gr.vhd:94
slv16 :=( others => '0') MEMSRC
Definition: pdp11_gr.vhd:97
slv16 :=( others => '0') MEMDST
Definition: pdp11_gr.vhd:98
slv16 :=( others => '0') R_PC
Definition: pdp11_gr.vhd:99
do_regmapPRNUM,PMODE,PRSET,PADDR,
Definition: pdp11_gr.vhd:76
slbit := '0' WE1
Definition: pdp11_gr.vhd:96
slv4 :=( others => '0') MADST
Definition: pdp11_gr.vhd:95
in MODE slv2
Definition: pdp11_gr.vhd:42
out DSRC slv16
Definition: pdp11_gr.vhd:47
out DDST slv16
Definition: pdp11_gr.vhd:48
in CLK slbit
Definition: pdp11_gr.vhd:38
in ADST slv3
Definition: pdp11_gr.vhd:41
in DIN slv16
Definition: pdp11_gr.vhd:39
in RSET slbit
Definition: pdp11_gr.vhd:43
in ASRC slv3
Definition: pdp11_gr.vhd:40
in BYTOP slbit
Definition: pdp11_gr.vhd:45
in WE slbit
Definition: pdp11_gr.vhd:44
in PCINC slbit
Definition: pdp11_gr.vhd:46
out PC slv16
Definition: pdp11_gr.vhd:50
Definition: pdp11.vhd:123
AWIDTH positive := 4
in DI slv( DWIDTH- 1 downto 0)
in ADDRB slv( AWIDTH- 1 downto 0)
in ADDRA slv( AWIDTH- 1 downto 0)
out DOB slv( DWIDTH- 1 downto 0)
out DOA slv( DWIDTH- 1 downto 0)
DWIDTH positive := 16
std_logic_vector( 14 downto 0) slv15
Definition: slvtypes.vhd:47
std_logic_vector( 3 downto 0) slv4
Definition: slvtypes.vhd:36
std_logic_vector( 2 downto 0) slv3
Definition: slvtypes.vhd:35
std_logic_vector( 15 downto 0) slv16
Definition: slvtypes.vhd:48
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector( 1 downto 0) slv2
Definition: slvtypes.vhd:34
std_logic_vector slv
Definition: slvtypes.vhd:31