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

Subversion Repositories lem1_9min

[/] [lem1_9min/] [trunk/] [lem1_9min_hw.vhd] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 marcus.erl
-- lem1_9min_test.vhd   test harness for lem1_9min, show moving HELLO WORLD on 7-seg display
2
--      targets Spartan-2/3 on Digilent board
3
--      output signals to 7-segment display
4
--      step via push buttons & switch
5
 
6
-- inst word: upper vertical bars, bit 7..0, bit 8 is left most top horzontal bar
7
-- progam counter: lower vertical bars, bit 7..0, bits 10..8 are left most bottom horzontal bars
8
-- ACC, CRY, WE, mem read bit: middle horizontal bars
9
-- step start signal: left most PB
10
-- step clk: right most PB
11
-- RUN/STEP: left most switch
12
-- uses 50 Mhz clock & board level reset
13
-- the eight discrete LEDs to be allocated later
14
-- 7-seg: 0: decimal point, 1: top, 2: top right, 3: bot right, 4: bottom, 5: bot left, 6: top left, 7: middle
15
-- dig_led: 3: left, 1: left mdle, 2: right mdle, 3: right
16
 
17
library ieee;
18
use IEEE.STD_LOGIC_1164.ALL;
19
use IEEE.std_logic_arith.all;
20
use IEEE.std_logic_misc.all;
21
use IEEE.std_logic_signed.all;
22
 
23
entity lem1_9min_test is port(
24
    clk:                in std_logic;
25
    reset:      in std_logic;
26
    start:      in std_logic;
27
    step:               in std_logic;
28
    run:                in std_logic;
29
    btn:                in std_logic_vector(3 downto 0); -- only #3 and #0 used, push for logic 1
30
    sw:         in std_logic_vector(7 downto 0); -- only #7 used, up for 1, down for 0
31
    led:                out std_logic_vector(7 downto 0);        -- not currently used
32
    seg:                out std_logic_vector(3 downto 0);        -- active low
33
    dig_led:    out std_logic_vector(7 downto 0));       -- active low
34
end entity lem1_9min_test;
35
 
36
architecture arch of lem1_9min_test is
37
signal cntr: std_logic_vector(31 downto 0);              --  clock divider for segement select & PB de-bounce
38
signal we, acc, cry, mem_bit: std_logic;
39
signal pc_reg: std_logic_vector(10 downto 0);
40
signal inst: std_logic_vector(8 downto 0);
41
signal btn3, btn0: std_logic;
42
signal sw7: std_logic;
43
signal dig3, dig2, dig1, dig0: std_logic_vector(7 downto 0);
44
 
45
component lem1_9 is port (
46
    clk:                in std_logic;
47
    reset:      in std_logic;
48
    start:      in std_logic;
49
    pc_reg:     out std_logic_vector(10 downto 0);
50
    mem_rd:     out std_logic_vector(8 downto 0);
51
    nxdata:     out std_logic;
52
    data_we:    out std_logic;
53
    acc_cpy:    out std_logic;
54
    cry_cpy:    out std_logic);
55
end component;
56
 
57
begin
58
 btn3 <= btn(3);
59
 btn0 <= btn(0);
60
 sw7  <= sw(7);
61
 
62
-- port maps
63
lem1_9min: entity lem1_9 port map(
64
        clk             => clk,
65
        reset   => reset,
66
        start   => start,
67
        pc_reg  => pc_reg,
68
        mem_rd  => inst,
69
        nxdata  => mem_bit,
70
        data_we => we,
71
        acc_cpy => acc,
72
        cry_cpy => cry);
73
 
74
count: process(clk) begin
75
  if rising_edge(clk) then
76
    cntr(31 downto 0) <= cntr(31 downto 0) + 1;
77
    if inst(5 downto 0) = "000000" AND we = '1' then led(0) <= acc; end if;
78
    if inst(5 downto 0) = "000001" AND we = '1' then led(1) <= acc; end if;
79
    if inst(5 downto 0) = "000010" AND we = '1' then led(2) <= acc; end if;
80
    if inst(5 downto 0) = "000011" AND we = '1' then led(3) <= acc; end if;
81
    if inst(5 downto 0) = "000100" AND we = '1' then led(4) <= acc; end if;
82
    if inst(5 downto 0) = "000101" AND we = '1' then led(5) <= acc; end if;
83
    if inst(5 downto 0) = "000110" AND we = '1' then led(6) <= acc; end if;
84
    if inst(5 downto 0) = "000111" AND we = '1' then led(7) <= acc; end if;
85
    if inst(5 downto 0) = "110000" AND we = '1' then dig_led(0) <= acc; end if;   -- dp
86
    if inst(5 downto 0) = "110001" AND we = '1' then dig_led(1) <= acc; end if;
87
    if inst(5 downto 0) = "110010" AND we = '1' then dig_led(2) <= acc; end if;
88
    if inst(5 downto 0) = "110011" AND we = '1' then dig_led(3) <= acc; end if;
89
    if inst(5 downto 0) = "110100" AND we = '1' then dig_led(4) <= acc; end if;
90
    if inst(5 downto 0) = "110101" AND we = '1' then dig_led(5) <= acc; end if;
91
    if inst(5 downto 0) = "110110" AND we = '1' then dig_led(6) <= acc; end if;
92
    if inst(5 downto 0) = "110111" AND we = '1' then dig_led(7) <= acc; end if;  -- top
93
    if inst(5 downto 0) = "111100" AND we = '1' then seg(0) <= acc; end if; -- LSB
94
    if inst(5 downto 0) = "111101" AND we = '1' then seg(1) <= acc; end if;
95
    if inst(5 downto 0) = "111110" AND we = '1' then seg(2) <= acc; end if;
96
    if inst(5 downto 0) = "111111" AND we = '1' then seg(3) <= acc; end if; -- MSB
97
    end if;
98
end process;
99
 
100
end arch;

powered by: WebSVN 2.1.0

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