OpenCores
URL https://opencores.org/ocsvn/mlite/mlite/trunk

Subversion Repositories mlite

[/] [mlite/] [trunk/] [vhdl/] [bus_mux.vhd] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 rhoads
---------------------------------------------------------------------
2
-- TITLE: Bus Multiplexer / Signal Router
3
-- AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
4
-- DATE CREATED: 2/8/01
5
-- FILENAME: bus_mux.vhd
6
-- PROJECT: MIPS CPU core
7
-- COPYRIGHT: Software placed into the public domain by the author.
8
--    Software 'as is' without warranty.  Author liable for nothing.
9
-- DESCRIPTION:
10
--    This entity is the main signal router.  
11
--    It multiplexes signals from multiple sources to the correct location.
12
--    The outputs are as follows:
13
--       a_bus        : goes to the ALU
14
--       b_bus        : goes to the ALU
15
--       reg_dest_out : goes to the register bank
16
--       take_branch  : a signal to pc_next
17
---------------------------------------------------------------------
18
library ieee;
19
use ieee.std_logic_1164.all;
20
use work.mips_pack.all;
21
 
22
entity bus_mux is
23
   port(imm_in       : in  std_logic_vector(15 downto 0);
24
        reg_source   : in  std_logic_vector(31 downto 0);
25
        a_mux        : in  a_source_type;
26
        a_out        : out std_logic_vector(31 downto 0);
27
 
28
        reg_target   : in  std_logic_vector(31 downto 0);
29
        b_mux        : in  b_source_type;
30
        b_out        : out std_logic_vector(31 downto 0);
31
 
32
        c_bus        : in  std_logic_vector(31 downto 0);
33
        c_memory     : in  std_logic_vector(31 downto 0);
34
        c_pc         : in  std_logic_vector(31 downto 0);
35 6 rhoads
        c_pc_plus4   : in  std_logic_vector(31 downto 0);
36 2 rhoads
        c_mux        : in  c_source_type;
37
        reg_dest_out : out std_logic_vector(31 downto 0);
38
 
39
        branch_func  : in  branch_function_type;
40
        take_branch  : out std_logic);
41
end; --entity bus_mux
42
 
43
architecture logic of bus_mux is
44
begin
45
--   type a_source_type is (a_from_reg_source, a_from_imm10_6);
46
--   type b_source_type is (b_from_reg_target, b_from_imm, b_from_signed_imm);
47
--   type c_source_type is (c_from_null, c_from_alu, c_from_shift, 
48
--      c_from_mult, c_from_memory, c_from_pc, c_from_imm_shift16,
49
--      c_from_reg_source_nez, c_from_reg_source_eqz);
50
amux: process(reg_source, imm_in, a_mux, c_pc)
51
begin
52
   a_out(31 downto 5) <= reg_source(31 downto 5);
53
   case a_mux is
54
   when a_from_reg_source =>
55
      a_out(4 downto 0) <= reg_source(4 downto 0);
56
   when a_from_imm10_6 =>
57
      a_out(4 downto 0) <= imm_in(10 downto 6);
58
   when others =>  --a_from_pc
59
      a_out <= c_pc;
60
   end case;
61
end process;
62
 
63
bmux: process(reg_target, imm_in, b_mux)
64
begin
65
   case b_mux is
66
   when b_from_reg_target  =>
67
      b_out <= reg_target;
68
   when b_from_imm =>
69
      b_out <= ZERO(31 downto 16) & imm_in;
70
   when b_from_signed_imm =>
71
      if imm_in(15) = '0' then
72
         b_out(31 downto 16) <= ZERO(31 downto 16);
73
      else
74
         b_out(31 downto 16) <= "1111111111111111";
75
      end if;
76
      b_out(15 downto 0) <= imm_in;
77
   when others =>             --b_from_immX4
78
      if imm_in(15) = '0' then
79
         b_out(31 downto 18) <= "00000000000000";
80
      else
81
         b_out(31 downto 18) <= "11111111111111";
82
      end if;
83
      b_out(17 downto 0) <= imm_in & "00";
84
   end case;
85
end process;
86
 
87 6 rhoads
cmux: process(c_bus, c_memory, c_pc, c_pc_plus4, imm_in, c_mux)
88 2 rhoads
begin
89
   case c_mux is
90
   when c_from_alu | c_from_shift | c_from_mult =>
91
      reg_dest_out <= c_bus;
92
   when c_from_memory =>
93
      reg_dest_out <= c_memory;
94
   when c_from_pc =>
95 6 rhoads
      reg_dest_out <= c_pc(31 downto 3) & "000"; --backup one opcode
96
   when c_from_pc_plus4 =>
97
      reg_dest_out <= c_pc_plus4;
98 2 rhoads
   when c_from_imm_shift16 =>
99
      reg_dest_out <= imm_in & ZERO(15 downto 0);
100
--   when from_reg_source_nez =>
101
--????
102
--   when from_reg_source_eqz =>
103
--????
104
   when others =>
105
      reg_dest_out <= c_bus;
106
   end case;
107
end process;
108
 
109
pc_mux: process(branch_func, reg_source, reg_target)
110
   variable is_equal : std_logic;
111
begin
112
   if reg_source = reg_target then
113
      is_equal := '1';
114
   else
115
      is_equal := '0';
116
   end if;
117
   case branch_func is
118
   when branch_ltz =>
119
      take_branch <= reg_source(31);
120
   when branch_lez =>
121
      take_branch <= reg_source(31) or is_equal;
122
   when branch_eq =>
123
      take_branch <= is_equal;
124
   when branch_ne =>
125
      take_branch <= not is_equal;
126
   when branch_gez =>
127
      take_branch <= not reg_source(31);
128
   when branch_gtz =>
129
      take_branch <= not reg_source(31) and not is_equal;
130
   when branch_yes =>
131
      take_branch <= '1';
132
   when others =>
133
      take_branch <= is_equal;
134
   end case;
135
end process;
136
 
137
end; --architecture logic
138
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.