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

Subversion Repositories plasma

[/] [plasma/] [tags/] [Version_1_0/] [vhdl/] [bus_mux.vhd] - Blame information for rev 352

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
        c_mux        : in  c_source_type;
36
        reg_dest_out : out std_logic_vector(31 downto 0);
37
 
38
        branch_func  : in  branch_function_type;
39
        take_branch  : out std_logic);
40
end; --entity bus_mux
41
 
42
architecture logic of bus_mux is
43
begin
44
--   type a_source_type is (a_from_reg_source, a_from_imm10_6);
45
--   type b_source_type is (b_from_reg_target, b_from_imm, b_from_signed_imm);
46
--   type c_source_type is (c_from_null, c_from_alu, c_from_shift, 
47
--      c_from_mult, c_from_memory, c_from_pc, c_from_imm_shift16,
48
--      c_from_reg_source_nez, c_from_reg_source_eqz);
49
amux: process(reg_source, imm_in, a_mux, c_pc)
50
begin
51
   a_out(31 downto 5) <= reg_source(31 downto 5);
52
   case a_mux is
53
   when a_from_reg_source =>
54
      a_out(4 downto 0) <= reg_source(4 downto 0);
55
   when a_from_imm10_6 =>
56
      a_out(4 downto 0) <= imm_in(10 downto 6);
57
   when others =>  --a_from_pc
58
      a_out <= c_pc;
59
   end case;
60
end process;
61
 
62
bmux: process(reg_target, imm_in, b_mux)
63
begin
64
   case b_mux is
65
   when b_from_reg_target  =>
66
      b_out <= reg_target;
67
   when b_from_imm =>
68
      b_out <= ZERO(31 downto 16) & imm_in;
69
   when b_from_signed_imm =>
70
      if imm_in(15) = '0' then
71
         b_out(31 downto 16) <= ZERO(31 downto 16);
72
      else
73
         b_out(31 downto 16) <= "1111111111111111";
74
      end if;
75
      b_out(15 downto 0) <= imm_in;
76
   when others =>             --b_from_immX4
77
      if imm_in(15) = '0' then
78
         b_out(31 downto 18) <= "00000000000000";
79
      else
80
         b_out(31 downto 18) <= "11111111111111";
81
      end if;
82
      b_out(17 downto 0) <= imm_in & "00";
83
   end case;
84
end process;
85
 
86
cmux: process(c_bus, c_memory, c_pc, imm_in, c_mux)
87
begin
88
   case c_mux is
89
   when c_from_alu | c_from_shift | c_from_mult =>
90
      reg_dest_out <= c_bus;
91
   when c_from_memory =>
92
      reg_dest_out <= c_memory;
93
   when c_from_pc =>
94
      reg_dest_out <= c_pc;
95
   when c_from_imm_shift16 =>
96
      reg_dest_out <= imm_in & ZERO(15 downto 0);
97
--   when from_reg_source_nez =>
98
--????
99
--   when from_reg_source_eqz =>
100
--????
101
   when others =>
102
      reg_dest_out <= c_bus;
103
   end case;
104
end process;
105
 
106
pc_mux: process(branch_func, reg_source, reg_target)
107
   variable is_equal : std_logic;
108
begin
109
   if reg_source = reg_target then
110
      is_equal := '1';
111
   else
112
      is_equal := '0';
113
   end if;
114
   case branch_func is
115
   when branch_ltz =>
116
      take_branch <= reg_source(31);
117
   when branch_lez =>
118
      take_branch <= reg_source(31) or is_equal;
119
   when branch_eq =>
120
      take_branch <= is_equal;
121
   when branch_ne =>
122
      take_branch <= not is_equal;
123
   when branch_gez =>
124
      take_branch <= not reg_source(31);
125
   when branch_gtz =>
126
      take_branch <= not reg_source(31) and not is_equal;
127
   when branch_yes =>
128
      take_branch <= '1';
129
   when others =>
130
      take_branch <= is_equal;
131
   end case;
132
end process;
133
 
134
end; --architecture logic
135
 

powered by: WebSVN 2.1.0

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