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

Subversion Repositories cpu_lecture

[/] [cpu_lecture/] [trunk/] [html/] [24_Listing_of_segment7.vhd.html] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jsauermann
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
"http://www.w3.org/TR/html4/strict.dtd">
3
<HTML>
4
<HEAD>
5
<TITLE>html/Listing_of_segment7.vhd</TITLE>
6
<META NAME="generator" CONTENT="HTML::TextToHTML v2.46">
7
<LINK REL="stylesheet" TYPE="text/css" HREF="lecture.css">
8
</HEAD>
9
<BODY>
10
<P><table class="ttop"><th class="tpre"><a href="23_Listing_of_register_file.vhd.html">Previous Lesson</a></th><th class="ttop"><a href="toc.html">Table of Content</a></th><th class="tnxt"><a href="25_Listing_of_status_reg.vhd.html">Next Lesson</a></th></table>
11
<hr>
12
 
13
<H1><A NAME="section_1">24 LISTING OF segment7.vhd</A></H1>
14
 
15
<pre class="vhdl">
16
 
17
  1     -------------------------------------------------------------------------------
18
  2     --
19
  3     -- Copyright (C) 2009, 2010 Dr. Juergen Sauermann
20
  4     --
21
  5     --  This code is free software: you can redistribute it and/or modify
22
  6     --  it under the terms of the GNU General Public License as published by
23
  7     --  the Free Software Foundation, either version 3 of the License, or
24
  8     --  (at your option) any later version.
25
  9     --
26
 10     --  This code is distributed in the hope that it will be useful,
27
 11     --  but WITHOUT ANY WARRANTY; without even the implied warranty of
28
 12     --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29
 13     --  GNU General Public License for more details.
30
 14     --
31
 15     --  You should have received a copy of the GNU General Public License
32
 16     --  along with this code (see the file named COPYING).
33
 17     --  If not, see http://www.gnu.org/licenses/.
34
 18     --
35
 19     -------------------------------------------------------------------------------
36
 20     -------------------------------------------------------------------------------
37
 21     --
38
 22     -- Module Name:    segment7 - Behavioral
39
 23     -- Create Date:    12:52:16 11/11/2009
40
 24     -- Description:    a 7 segment LED display interface.
41
 25     --
42
 26     -------------------------------------------------------------------------------
43
 27     --
44
 28     library IEEE;
45
 29     use IEEE.STD_LOGIC_1164.ALL;
46
 30     use IEEE.STD_LOGIC_ARITH.ALL;
47
 31     use IEEE.STD_LOGIC_UNSIGNED.ALL;
48
 32
49
 33     entity segment7 is
50
 34         port ( I_CLK        : in  std_logic;
51
 35
52
 36                I_CLR        : in  std_logic;
53
 37                I_OPC        : in  std_logic_vector(15 downto 0);
54
 38                I_PC         : in  std_logic_vector(15 downto 0);
55
 39
56
 40                Q_7_SEGMENT : out std_logic_vector( 6 downto 0));
57
 41     end segment7;
58
 42
59
 43     --      Signal      Loc Alt
60
 44     ---------------------------
61
 45     --      SEG_LED(0)  V3  A
62
 46     --      SEG_LED(1)  V4  B
63
 47     --      SEG_LED(2)  W3  C
64
 48     --      SEG_LED(3)  T4  D
65
 49     --      SEG_LED(4)  T3  E
66
 50     --      SEG_LED(5)  U3  F
67
 51     --      SEG_LED(6)  U4  G
68
 52     --
69
 53     architecture Behavioral of segment7 is
70
 54
71
 55     function lmap(VAL: std_logic_vector( 3 downto 0))
72
 56              return std_logic_vector is
73
 57     begin
74
 58         case VAL is         --      6543210
75
 59             when "0000" =>  return "0111111";   -- 0
76
 60             when "0001" =>  return "0000110";   -- 1
77
 61             when "0010" =>  return "1011011";   -- 2
78
 62             when "0011" =>  return "1001111";   -- 3
79
 63             when "0100" =>  return "1100110";   -- 4    ----A----       ----0----
80
 64             when "0101" =>  return "1101101";   -- 5    |       |       |       |
81
 65             when "0110" =>  return "1111101";   -- 6    F       B       5       1
82
 66             when "0111" =>  return "0000111";   -- 7    |       |       |       |
83
 67             when "1000" =>  return "1111111";   -- 8    +---G---+       +---6---+
84
 68             when "1001" =>  return "1101111";   -- 9    |       |       |       |
85
 69             when "1010" =>  return "1110111";   -- A    E       C       4       2
86
 70             when "1011" =>  return "1111100";   -- b    |       |       |       |
87
 71             when "1100" =>  return "0111001";   -- C    ----D----       ----3----
88
 72             when "1101" =>  return "1011110";   -- d
89
 73             when "1110" =>  return "1111001";   -- E
90
 74             when others =>  return "1110001";   -- F
91
 75         end case;
92
 76     end;
93
 77
94
 78     signal L_CNT            : std_logic_vector(27 downto 0);
95
 79     signal L_OPC            : std_logic_vector(15 downto 0);
96
 80     signal L_PC             : std_logic_vector(15 downto 0);
97
 81     signal L_POS            : std_logic_vector( 3 downto 0);
98
 82
99
 83     begin
100
 84
101
 85         process(I_CLK)    -- 20 MHz
102
 86         begin
103
 87             if (rising_edge(I_CLK)) then
104
 88                 if (I_CLR = '1') then
105
 89                     L_POS <= "0000";
106
 90                     L_CNT <= X"0000000";
107
 91                     Q_7_SEGMENT <= "1111111";
108
 92                 else
109
 93                     L_CNT <= L_CNT + X"0000001";
110
 94                     if (L_CNT =  X"0C00000") then
111
 95                         Q_7_SEGMENT <= "1111111";      -- blank
112
 96                     elsif (L_CNT =  X"1000000") then
113
 97                         L_CNT <= X"0000000";
114
 98                         L_POS <= L_POS + "0001";
115
 99                         case L_POS is
116
100                             when "0000" =>  -- blank
117
101                                 Q_7_SEGMENT <= "1111111";
118
102                             when "0001" =>
119
103                                 L_PC <= I_PC;       -- sample PC
120
104                                 L_OPC <= I_OPC;     -- sample OPC
121
105                                 Q_7_SEGMENT <= not lmap(L_PC(15 downto 12));
122
106                             when "0010" =>
123
107                                 Q_7_SEGMENT <= not lmap(L_PC(11 downto  8));
124
108                             when "0011" =>
125
109                                 Q_7_SEGMENT <= not lmap(L_PC( 7 downto  4));
126
110                             when "0100" =>
127
111                                 Q_7_SEGMENT <= not lmap(L_PC( 3 downto  0));
128
112                             when "0101" =>  -- minus
129
113                                 Q_7_SEGMENT <= "0111111";
130
114                             when "0110" =>
131
115                                 Q_7_SEGMENT <= not lmap(L_OPC(15 downto 12));
132
116                             when "0111" =>
133
117                                 Q_7_SEGMENT <= not lmap(L_OPC(11 downto  8));
134
118                             when "1000" =>
135
119                                 Q_7_SEGMENT <= not lmap(L_OPC( 7 downto  4));
136
120                             when "1001" =>
137
121                                 Q_7_SEGMENT <= not lmap(L_OPC( 3 downto  0));
138
122                                 L_POS <= "0000";
139
123                             when others =>
140
124                                 L_POS <= "0000";
141
125                         end case;
142
126                     end if;
143
127                 end if;
144
128             end if;
145
129         end process;
146
130
147
131     end Behavioral;
148
132
149
<pre class="filename">
150
src/segment7.vhd
151
</pre></pre>
152
<P>
153
 
154
<P><hr><BR>
155
<table class="ttop"><th class="tpre"><a href="23_Listing_of_register_file.vhd.html">Previous Lesson</a></th><th class="ttop"><a href="toc.html">Table of Content</a></th><th class="tnxt"><a href="25_Listing_of_status_reg.vhd.html">Next Lesson</a></th></table>
156
</BODY>
157
</HTML>

powered by: WebSVN 2.1.0

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