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

Subversion Repositories plasma

[/] [plasma/] [trunk/] [vhdl/] [bus_mux.vhd] - Blame information for rev 417

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 43 rhoads
-- PROJECT: Plasma CPU core
7 2 rhoads
-- 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 86 rhoads
--       take_branch  : goes to pc_next
17 2 rhoads
---------------------------------------------------------------------
18
library ieee;
19
use ieee.std_logic_1164.all;
20 39 rhoads
use work.mlite_pack.all;
21 2 rhoads
 
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 139 rhoads
        c_pc         : in  std_logic_vector(31 downto 2);
35
        c_pc_plus4   : in  std_logic_vector(31 downto 2);
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 128 rhoads
 
46 139 rhoads
--Determine value of a_bus
47 2 rhoads
amux: process(reg_source, imm_in, a_mux, c_pc)
48
begin
49
   case a_mux is
50 128 rhoads
   when A_FROM_REG_SOURCE =>
51 75 rhoads
      a_out <= reg_source;
52 128 rhoads
   when A_FROM_IMM10_6 =>
53
      a_out <= ZERO(31 downto 5) & imm_in(10 downto 6);
54
   when A_FROM_PC =>
55 139 rhoads
      a_out <= c_pc & "00";
56 128 rhoads
   when others =>
57 139 rhoads
      a_out <= c_pc & "00";
58 2 rhoads
   end case;
59
end process;
60
 
61 139 rhoads
--Determine value of b_bus
62 2 rhoads
bmux: process(reg_target, imm_in, b_mux)
63
begin
64
   case b_mux is
65 128 rhoads
   when B_FROM_REG_TARGET =>
66 2 rhoads
      b_out <= reg_target;
67 128 rhoads
   when B_FROM_IMM =>
68 2 rhoads
      b_out <= ZERO(31 downto 16) & imm_in;
69 128 rhoads
   when B_FROM_SIGNED_IMM =>
70 2 rhoads
      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 128 rhoads
   when B_FROM_IMMX4 =>
77 2 rhoads
      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 139 rhoads
   when others =>
84 128 rhoads
      b_out <= reg_target;
85 2 rhoads
   end case;
86
end process;
87
 
88 139 rhoads
--Determine value of c_bus                                                              
89 6 rhoads
cmux: process(c_bus, c_memory, c_pc, c_pc_plus4, imm_in, c_mux)
90 2 rhoads
begin
91
   case c_mux is
92 128 rhoads
   when C_FROM_ALU =>  -- | C_FROM_SHIFT | C_FROM_MULT =>
93 2 rhoads
      reg_dest_out <= c_bus;
94 128 rhoads
   when C_FROM_MEMORY =>
95 2 rhoads
      reg_dest_out <= c_memory;
96 128 rhoads
   when C_FROM_PC =>
97 139 rhoads
      reg_dest_out <= c_pc(31 downto 2) & "00";
98 128 rhoads
   when C_FROM_PC_PLUS4 =>
99 139 rhoads
      reg_dest_out <= c_pc_plus4 & "00";
100 128 rhoads
   when C_FROM_IMM_SHIFT16 =>
101 2 rhoads
      reg_dest_out <= imm_in & ZERO(15 downto 0);
102
   when others =>
103
      reg_dest_out <= c_bus;
104
   end case;
105
end process;
106
 
107 139 rhoads
--Determine value of take_branch
108 2 rhoads
pc_mux: process(branch_func, reg_source, reg_target)
109
   variable is_equal : std_logic;
110
begin
111
   if reg_source = reg_target then
112
      is_equal := '1';
113
   else
114
      is_equal := '0';
115
   end if;
116
   case branch_func is
117 128 rhoads
   when BRANCH_LTZ =>
118 2 rhoads
      take_branch <= reg_source(31);
119 128 rhoads
   when BRANCH_LEZ =>
120 2 rhoads
      take_branch <= reg_source(31) or is_equal;
121 128 rhoads
   when BRANCH_EQ =>
122 2 rhoads
      take_branch <= is_equal;
123 128 rhoads
   when BRANCH_NE =>
124 2 rhoads
      take_branch <= not is_equal;
125 128 rhoads
   when BRANCH_GEZ =>
126 2 rhoads
      take_branch <= not reg_source(31);
127 128 rhoads
   when BRANCH_GTZ =>
128 2 rhoads
      take_branch <= not reg_source(31) and not is_equal;
129 128 rhoads
   when BRANCH_YES =>
130 2 rhoads
      take_branch <= '1';
131
   when others =>
132 139 rhoads
      take_branch <= '0';
133 2 rhoads
   end case;
134
end process;
135
 
136
end; --architecture logic

powered by: WebSVN 2.1.0

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