feaa63d45cb3d42195b838300d55df07aaaadbaf
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

1) LIBRARY ieee;
2) USE ieee.std_logic_1164.all;
3) USE ieee.numeric_std.all;
4) USE work.mips_types.all;
5) 
6) ENTITY e_mips_core IS
7)     PORT (
8)         rst:   IN  std_logic;
9)         clk:   IN  std_logic;
10)         o_res: OUT std_logic_vector(31 DOWNTO 0)
11)     );
12) END ENTITY e_mips_core;
13) 
14) ARCHITECTURE a_mips_core OF e_mips_core IS
15) 
16)     SIGNAL r_instr: std_logic_vector(31 DOWNTO 0);
17) 
Stefan Schuermans rename src/dest to more gen...

Stefan Schuermans authored 12 years ago

18)     SIGNAL s_reg_s:  std_logic_vector( 4 DOWNTO 0);
19)     SIGNAL s_reg_t:  std_logic_vector( 4 DOWNTO 0);
20)     SIGNAL s_reg_d:  std_logic_vector( 4 DOWNTO 0);
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

21)     SIGNAL s_imm_a:  std_logic_vector( 4 DOWNTO 0);
22)     SIGNAL s_imm_16: std_logic_vector(15 DOWNTO 0);
23)     SIGNAL s_imm_26: std_logic_vector(25 DOWNTO 0);
24)     SIGNAL s_op:     t_op;
25)     SIGNAL s_link:   t_link;
26)     SIGNAL s_cmp:    t_cmp;
27)     SIGNAL s_alu:    t_alu;
28)     SIGNAL s_imm:    t_imm;
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

29)     
30)     SIGNAL s_val_s: std_logic_vector(31 DOWNTO 0);
31)     SIGNAL s_val_t: std_logic_vector(31 DOWNTO 0);
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

32) 
33)     SIGNAL s_op1: std_logic_vector(31 DOWNTO 0);
34)     SIGNAL s_op2: std_logic_vector(31 DOWNTO 0);
Stefan Schuermans added register file

Stefan Schuermans authored 12 years ago

35)     SIGNAL s_res: std_logic_vector(31 DOWNTO 0);
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

36) 
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

37)     SIGNAL s_reg_wr_no:   std_logic_vector( 4 DOWNTO 0);
38)     SIGNAL s_reg_wr_data: std_logic_vector(31 DOWNTO 0);
39)     SIGNAL s_reg_wr_en:   std_logic;
40) 
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

41)     COMPONENT e_mips_decoder IS
42)         PORT (
43)             i_instr:  IN  std_logic_vector(31 DOWNTO 0);
Stefan Schuermans rename src/dest to more gen...

Stefan Schuermans authored 12 years ago

44)             o_reg_s:  OUT std_logic_vector( 4 DOWNTO 0);
45)             o_reg_t:  OUT std_logic_vector( 4 DOWNTO 0);
46)             o_reg_d:  OUT std_logic_vector( 4 DOWNTO 0);
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

47)             o_imm_a:  OUT std_logic_vector( 4 DOWNTO 0);
48)             o_imm_16: OUT std_logic_vector(15 DOWNTO 0);
49)             o_imm_26: OUT std_logic_vector(25 DOWNTO 0);
50)             o_op:     OUT t_op;
51)             o_link:   OUT t_link;
52)             o_cmp:    OUT t_cmp;
53)             o_alu:    OUT t_alu;
54)             o_imm:    OUT t_imm
55)         );
56)     END COMPONENT e_mips_decoder;
57) 
Stefan Schuermans added register file

Stefan Schuermans authored 12 years ago

58)     COMPONENT e_mips_regs IS
59)         PORT (
60)             rst:         IN  std_logic;
61)             clk:         IN  std_logic;
62)             i_rd_a_no:   IN  std_logic_vector( 4 DOWNTO 0);
63)             o_rd_a_data: OUT std_logic_vector(31 DOWNTO 0);
64)             i_rd_b_no:   IN  std_logic_vector( 4 DOWNTO 0);
65)             o_rd_b_data: OUT std_logic_vector(31 DOWNTO 0);
66)             i_wr_no:     IN  std_logic_vector( 4 DOWNTO 0);
67)             i_wr_data:   IN  std_logic_vector(31 DOWNTO 0);
68)             i_wr_en:     IN  std_logic
69)         );
70)     END COMPONENT e_mips_regs;
71) 
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

72)     COMPONENT e_mips_alu IS
73)         PORT (
74)             i_alu: IN  t_alu;
75)             i_op1: IN  std_logic_vector(31 DOWNTO 0);
76)             i_op2: IN  std_logic_vector(31 DOWNTO 0);
77)             o_res: OUT std_logic_vector(31 DOWNTO 0)
78)         );
79)     END COMPONENT e_mips_alu;
80) 
81) BEGIN
82) 
83)     decoder: e_mips_decoder
84)         PORT MAP (
85)             i_instr  => r_instr,
Stefan Schuermans rename src/dest to more gen...

Stefan Schuermans authored 12 years ago

86)             o_reg_s  => s_reg_s,
87)             o_reg_t  => s_reg_t,
88)             o_reg_d  => s_reg_d,
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

89)             o_imm_a  => s_imm_a,
90)             o_imm_16 => s_imm_16,
91)             o_imm_26 => s_imm_26,
92)             o_op     => s_op,
93)             o_link   => s_link,
94)             o_cmp    => s_cmp,
95)             o_alu    => s_alu,
96)             o_imm    => s_imm
97)         );
98) 
Stefan Schuermans added register file

Stefan Schuermans authored 12 years ago

99)     regs: e_mips_regs
100)         PORT MAP (
101)             rst         => rst,
102)             clk         => clk,
Stefan Schuermans rename src/dest to more gen...

Stefan Schuermans authored 12 years ago

103)             i_rd_a_no   => s_reg_s,
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

104)             o_rd_a_data => s_val_s,
Stefan Schuermans rename src/dest to more gen...

Stefan Schuermans authored 12 years ago

105)             i_rd_b_no   => s_reg_t,
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

106)             o_rd_b_data => s_val_t,
107)             i_wr_no     => s_reg_wr_no,
108)             i_wr_data   => s_reg_wr_data,
109)             i_wr_en     => s_reg_wr_en
Stefan Schuermans added register file

Stefan Schuermans authored 12 years ago

110)         );
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

111) 
112)     alu: e_mips_alu
113)         PORT MAP (
114)             i_alu => s_alu,
115)             i_op1 => s_op1,
116)             i_op2 => s_op2,
Stefan Schuermans added register file

Stefan Schuermans authored 12 years ago

117)             o_res => s_res
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

118)         );
119) 
120)     p_dummy_fetch: PROCESS(rst, clk)
121)     BEGIN
122)         IF rst = '1' THEN
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

123)             r_instr <= (OTHERS => '0');
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

124)         ELSIF rising_edge(clk) THEN
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

125)             r_instr <= std_logic_vector(unsigned(r_instr) +
126)                                         to_unsigned(1, 32));
Stefan Schuermans start of MIPS core: begin o...

Stefan Schuermans authored 12 years ago

127)         END IF;
128)     END PROCESS p_dummy_fetch;
129) 
Stefan Schuermans implement correctly writing...

Stefan Schuermans authored 12 years ago

130)     p_alu_in: PROCESS(s_op, s_imm, s_val_s, s_val_t, s_imm_a, s_imm_16)
131)     BEGIN
132)         s_op1 <= (OTHERS => '0');
133)         s_op2 <= (OTHERS => '0');
134)         IF s_op = op_alu THEN
135)             CASE s_imm IS
136)                 WHEN imm_none =>
137)                     s_op1 <= s_val_s;
138)                     s_op2 <= s_val_t;
139)                 WHEN imm_a =>
140)                     s_op1(4 DOWNTO 0) <= s_imm_a;
141)                     s_op2 <= s_val_t;
142)                 WHEN imm_16se =>
143)                     s_op1 <= s_val_s;
144)                     s_op2(15 DOWNTO 0) <= s_imm_16;
145)                     IF (s_imm_16(15) = '1') THEN
146)                         s_op2(31 DOWNTO 16) <= (OTHERS => '1');
147)                     END IF;
148)                 WHEN imm_16ze =>
149)                     s_op1 <= s_val_s;
150)                     s_op2(15 DOWNTO 0) <= s_imm_16;
151)                 WHEN OTHERS => NULL;
152)             END CASE;
153)         END IF;
154)     END PROCESS p_alu_in;
155) 
156)     p_reg_wr: PROCESS(s_op, s_imm, s_reg_t, s_reg_d)
157)     BEGIN
158)         s_reg_wr_no   <= (OTHERS => '0');
159)         s_reg_wr_data <= (OTHERS => '0');
160)         s_reg_wr_en   <= '0';
161)         IF s_op = op_alu THEN
162)             CASE s_imm IS
163)                 WHEN imm_none | imm_a =>
164)                     s_reg_wr_no   <= s_reg_d;
165)                     s_reg_wr_data <= s_res;
166)                     s_reg_wr_en   <= '1';
167)                 WHEN imm_16se | imm_16ze =>
168)                     s_reg_wr_no   <= s_reg_t;
169)                     s_reg_wr_data <= s_res;
170)                     s_reg_wr_en   <= '1';
171)                 WHEN OTHERS => NULL;
172)             END CASE;
173)         END IF;
174)     END PROCESS p_reg_wr;
175) 
Stefan Schuermans added register file

Stefan Schuermans authored 12 years ago

176)     o_res <= s_res;
177)