-
Notifications
You must be signed in to change notification settings - Fork 0
/
controlunit.vhd
91 lines (71 loc) · 1.74 KB
/
controlunit.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
-- File: controlunit.vhd
-- Generated by MyHDL 1.0dev
-- Date: Tue Jun 28 23:51:44 2016
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
use std.textio.all;
use work.pck_myhdl_10.all;
entity controlunit is
port (
reset: in std_logic;
clock: in std_logic;
operand: in unsigned(9 downto 0);
result: out unsigned(9 downto 0)
);
end entity controlunit;
architecture MyHDL of controlunit is
signal sel: unsigned(1 downto 0);
signal opb: unsigned(3 downto 0);
signal opa: unsigned(3 downto 0);
procedure MYHDL3_mul(
c: out unsigned;
a: in unsigned;
b: in unsigned) is
begin
c <= (a * b);
end procedure MYHDL3_mul;
procedure MYHDL4_add(
c: out unsigned;
a: in unsigned;
b: in unsigned) is
begin
c <= (a + b);
end procedure MYHDL4_add;
procedure MYHDL5_sub(
c: out unsigned;
a: in unsigned;
b: in unsigned) is
begin
c <= (a - b);
end procedure MYHDL5_sub;
procedure MYHDL6_shift_l(
c: out unsigned;
a: in unsigned;
b: in unsigned) is
begin
c <= shift_left(a, b);
end procedure MYHDL6_shift_l;
begin
sel <= operand(10-1 downto 8);
opa <= operand(8-1 downto 4);
opb <= operand(4-1 downto 0);
CONTROLUNIT_ASSIGN2: process (clock, reset) is
begin
if (reset = '1') then
elsif rising_edge(clock) then
case sel is
when "00" =>
MYHDL3_mul(result, opa, opb);
when "01" =>
MYHDL4_add(result, opa, opb);
when "10" =>
MYHDL5_sub(result, opa, opb);
when "11" =>
MYHDL6_shift_l(result, opa, opb);
when others =>
null;
end case;
end if;
end process CONTROLUNIT_ASSIGN2;
end architecture MyHDL;