Merge branch 'master' of git@wien.tomnetworks.com:hwmod
authorAlexander Oh <oh.a@gmx.at>
Wed, 26 May 2010 01:34:54 +0000 (03:34 +0200)
committerAlexander Oh <oh.a@gmx.at>
Wed, 26 May 2010 01:34:54 +0000 (03:34 +0200)
spartan3e/Makefile
spartan3e/spartan3e.ucf
spec/speck.tex
src/TODO
src/beh_history_tb.vhd
src/beh_loopback_tb.vhd
src/beh_uart_rx_tb.vhd
src/calc.vhd
src/calc_s3e.vhd
src/uart_rx.vhd

index dd3a8acebc277ab3a6f848d3e320a97ee63bb0a6..0ce3e189425e2ffcda5698b44060da105be70659 100644 (file)
@@ -12,6 +12,8 @@ PROJ_VHDL = alu.vhd \
        parser.vhd \
        scanner.vhd \
        sp_ram.vhd \
+       uart_rx.vhd \
+       uart_tx.vhd \
        textmode_vga/console_sm.vhd \
        textmode_vga/console_sm_beh.vhd \
        textmode_vga/console_sm_sync.vhd \
@@ -36,7 +38,20 @@ PROJ_VHDL = alu.vhd \
        ps2/ps2_keyboard_controller_pkg.vhd \
        ps2/ps2_transceiver.vhd \
        ps2/ps2_transceiver_beh.vhd \
-       ps2/ps2_transceiver_pkg.vhd
+       ps2/ps2_transceiver_pkg.vhd \
+       debouncing/counter.vhd \
+       debouncing/counter_beh.vhd \
+       debouncing/debounce.vhd \
+       debouncing/debounce_fsm.vhd \
+       debouncing/debounce_fsm_beh.vhd \
+       debouncing/debounce_pkg.vhd \
+       debouncing/debounce_struct.vhd \
+       debouncing/event_counter.vhd \
+       debouncing/event_counter_beh.vhd \
+       debouncing/event_counter_pkg.vhd \
+       debouncing/sync.vhd \
+       debouncing/sync_beh.vhd \
+       debouncing/sync_pkg.vhd
 
 PROJ_VHDL := $(foreach n,$(PROJ_VHDL),$(VHDL_DIR)/$(n))
 
index fc193cd85267cccb69e54683dd34b31b4b4d4f49..5e47e3b741cf984b7705cdf9ef52748e145cb132 100644 (file)
@@ -129,8 +129,8 @@ NET "CLK_50MHZ" PERIOD = 20 ns HIGH 40 %;
 #NET "SF_D<11>" LOC = "M15" | IOSTANDARD = LVCMOS33 | DRIVE = 4 | SLEW = SLOW ;
 # ==== Discrete LEDs (LED) ====
 # These are shared connections with the FX2 connector
-NET "LED0" LOC = "F12" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
-NET "LED1" LOC = "E12" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
+#NET "LED0" LOC = "F12" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
+#NET "LED1" LOC = "E12" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
 #NET "LED<2>" LOC = "E11" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
 #NET "LED<3>" LOC = "F11" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
 #NET "LED<4>" LOC = "C11" | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 8 ;
@@ -145,8 +145,8 @@ NET "PS2_DATA" LOC = "G13" | IOSTANDARD = LVCMOS33 ;
 #NET "ROT_B" LOC = "G18" | IOSTANDARD = LVTTL | PULLUP ;
 #NET "ROT_CENTER" LOC = "V16" | IOSTANDARD = LVTTL | PULLDOWN ;
 # ==== RS-232 Serial Ports (RS232) ====
-#NET "RS232_DCE_RXD" LOC = "F8" | IOSTANDARD = LVTTL ;
-#NET "RS232_DCE_TXD" LOC = "E8" | IOSTANDARD = LVTTL | DRIVE = 8 | SLEW = SLOW ;
+NET "rxd" LOC = "E8" | IOSTANDARD = LVTTL ;
+NET "txd" LOC = "F8" | IOSTANDARD = LVTTL | DRIVE = 8 | SLEW = SLOW ;
 #NET "RS232_DTE_RXD" LOC = "U8" | IOSTANDARD = LVTTL ;
 #NET "RS232_DTE_TXD" LOC = "M13" | IOSTANDARD = LVTTL | DRIVE = 8 | SLEW = SLOW ;
 # ==== DDR SDRAM (SD) ==== (I/O Bank 3, VCCO=2.5V)
index 1622304d6794eac66c37010a3dddc487545588cd..ebcd8d293e0738c8ae31a8481081c0944b49582d 100644 (file)
@@ -631,6 +631,7 @@ wirklich $\Rightarrow$ Tonne
 \item Display $\Rightarrow$ History: die Breite f\"ur \emph{d\_zeile} muss
 ebenfalls so breit wie \emph{p\_zeile} sein (zumindest vereinfacht das die
 Implementierung)
+\item RS232: \emph{tx\_done} hinzugefuegt.
 \end{itemize}
 
 \end{document}
index f71752a73b4df4c12b5c35db201e1719f788713a..f3e16def36c80a1b72c31548ea5620dd291a0a62 100644 (file)
--- a/src/TODO
+++ b/src/TODO
@@ -1,21 +1,11 @@
-- debounce fuer sys_res_n und btnA -- einfach die debounce entity vom example
-  hernehmen
+- debounce fuer btnA -- einfach die debounce entity vom example hernehmen
 
 
 - rs232/pc-kommunikation: RAM dumpen
 
 
-- uart rx oversampling, uart rx synchronizen (vlg. debouncing/sync*.vhd)
-
-
-- postlayout: nochmal testen obs im tilab wirklich ned geht.
-
-
 - gen_pkg: unsigned fuer hspalte, hzeile
 
-== BUGS ==
-- warum ist in beh_history s_done und finished manchmal 'X'?
-
 
 == low prio ==
 - logic elements eliminieren
@@ -27,6 +17,8 @@
 - wie detailiert muessen die screenshots der simulationen sein?
 - warum ist auf seite 14 im foliensatz "VHDL_Architecture" "directly at
   instantation" durchgestrichen? :/ (wird so ziemlich ueberall verwendet hier)
+- postlayout: geht im tilab nicht... reicht screenshot?
+
 
 
 == FAQ =
index 84d8cc1a34b0be56bcdb14c17c6d9adbf648b187..45712266385ac9e74c85092135fa50b5fbd70063 100644 (file)
@@ -237,18 +237,13 @@ begin
                                        run_inner := false;
                                        if s_backspace = '1' or s_take = '1' then
                                                icwait(sys_clk, 1);
-                                               s_done <= '1';
                                                wait on s_take; -- = '0'
                                                icwait(sys_clk, 1);
-                                               s_done <= '0';
                                        elsif do_it = '1' then
                                                -- dauert normalweiser noch laenger (parser braucht
                                                -- relativ lange)
                                                icwait(sys_clk, 7);
-                                               finished <= '1';
                                                wait on do_it; -- = '0'
-                                               icwait(sys_clk, 1);
-                                               finished <= '0';
                                                icwait(sys_clk, 850);
 
                                                run_tc := false;
index a44bdbdadbdb5823eafb07ddbed032a48755a66f..5e040f06b33fe4ed897fd34ebdba9cec7a30f509 100644 (file)
@@ -99,12 +99,12 @@ begin
                -- 1. parameter: testfallnummer
                -- 2. parameter: STARTBIT (1 bit) - immer '0' | 8 DATENBITS | 1 STOPBIT - immer '1'
                -- 3. parameter: byte das rauskommen soll
-               exec_tc(1, b"0000011111", b"00001111");
-               exec_tc(2, b"0101010101", b"10101010");
-               exec_tc(3, b"0110011001", b"11001100");
-               exec_tc(4, b"0001100111", b"00110011");
-               exec_tc(5, b"0010101011", b"01010101");
-               exec_tc(6, b"0100110111", b"10011011");
+               exec_tc(1, b"0000011111", b"11110000");
+               exec_tc(2, b"0101010101", b"01010101");
+               exec_tc(3, b"0110011001", b"00110011");
+               exec_tc(4, b"0001100111", b"11001100");
+               exec_tc(5, b"0010101011", b"10101010");
+               exec_tc(6, b"0100110111", b"11011001");
 
                stop <= true;
                wait;
index 26adbda22b46f13419dc05fe61530b19af389af3..f5e3c6936b654edb597ee135df99669ab119517a 100644 (file)
@@ -75,13 +75,13 @@ begin
 
                -- 1. parameter: testfallnummer
                -- 2. parameter: STARTBIT (1 bit) - immer '0' | 8 DATENBITS | 1 STOPBIT - immer '1'
-               -- 3. parameter: byte das rauskommen soll
-               exec_tc(1, b"0000011111", b"00001111");
-               exec_tc(2, b"0101010101", b"10101010");
-               exec_tc(3, b"0110011001", b"11001100");
-               exec_tc(4, b"0001100111", b"00110011");
-               exec_tc(5, b"0010101011", b"01010101");
-               exec_tc(6, b"0100110111", b"10011011");
+               -- 3. parameter: byte das rauskommen soll (umgekehrte reihenfolge)
+               exec_tc(1, b"0000011111", b"11110000");
+               exec_tc(2, b"0101010101", b"01010101");
+               exec_tc(3, b"0110011001", b"00110011");
+               exec_tc(4, b"0001100111", b"11001100");
+               exec_tc(5, b"0010101011", b"10101010");
+               exec_tc(6, b"0100110111", b"11011001");
 
                stop <= true;
                wait;
index bd4e903f80c51dd859479a9dd96270054c6309a0..2175ee932086b666c40f8f46c77cfa78d855c23e 100644 (file)
@@ -65,7 +65,6 @@ architecture top of calc is
        signal rx_data : std_logic_vector (7 downto 0);
        signal tx_new, tx_done : std_logic;
        signal tx_data : std_logic_vector (7 downto 0);
-       signal txd_out : std_logic;
 begin
        -- vga/ipcore
        textmode_vga_inst : entity work.textmode_vga(struct)
@@ -248,7 +247,7 @@ begin
        port map (
                sys_clk => sys_clk,
                sys_res_n => sys_res_n,
-               txd => txd_out,
+               txd => txd,
                tx_data => tx_data,
                tx_new => tx_new,
                tx_done => tx_done
index c43749d699d003a3243024e65159bc9dd5d3d3fc..040034ad3ec94bd49496f72f503241d0cd7d12b4 100644 (file)
@@ -6,6 +6,7 @@ use work.textmode_vga_component_pkg.all;
 use work.textmode_vga_pkg.all;
 use work.textmode_vga_platform_dependent_pkg.all;
 use work.ps2_keyboard_controller_pkg.all;
+use work.sync_pkg.all;
 
 entity calc is
        port (
@@ -14,7 +15,8 @@ entity calc is
                -- btnA
                -- TODO: pins
                -- rs232
-               -- TODO: pins
+               rxd : in std_logic;
+               txd : out std_logic;
                -- vga
                vsync_n : out std_logic;
                hsync_n : out std_logic;
@@ -23,10 +25,7 @@ entity calc is
                b : out std_logic_vector(BLUE_BITS - 1 downto 0);
                -- ps/2
                ps2_clk : inout std_logic;
-               ps2_data : inout std_logic;
-               -- debug
-               led0 : out std_logic;
-               led1 : out std_logic
+               ps2_data : inout std_logic
        );
 end entity calc;
 
@@ -60,9 +59,12 @@ architecture top of calc is
        signal p_finished : std_logic;
        -- parser/scanner
        signal do_it, finished : std_logic;
+       -- rs232
+       signal rx_new, rxd_sync : std_logic;
+       signal rx_data : std_logic_vector (7 downto 0);
+       signal tx_new, tx_done : std_logic;
+       signal tx_data : std_logic_vector (7 downto 0);
 begin
-       led0 <= '0';
-       led1 <= '1';
        sys_res_n <= not sys_res;
 
        -- vga/ipcore
@@ -194,4 +196,46 @@ begin
                ps2_clk => ps2_clk,
                ps2_data => ps2_data
        );
+
+       -- synchronizer fuer rxd
+       sync_rxd_inst : entity work.sync(beh)
+       generic map (
+               SYNC_STAGES => 2,
+               RESET_VALUE => '1'
+       )
+       port map (
+               sys_clk => CLK_50MHZ,
+               sys_res_n => sys_res_n,
+               data_in => rxd,
+               data_out => rxd_sync
+       );
+
+       -- rs232-rx
+       rs232rx_inst : entity work.uart_rx(beh)
+       generic map (
+               CLK_FREQ => 50000000,
+               BAUDRATE => 115200
+       )
+       port map (
+               sys_clk => CLK_50MHZ,
+               sys_res_n => sys_res_n,
+               rxd => rxd_sync,
+               rx_data => rx_data,
+               rx_new => rx_new
+       );
+
+       -- rs232-tx
+       rs232tx_inst : entity work.uart_tx(beh)
+       generic map (
+               CLK_FREQ => 50000000,
+               BAUDRATE => 115200
+       )
+       port map (
+               sys_clk => CLK_50MHZ,
+               sys_res_n => sys_res_n,
+               txd => txd,
+               tx_data => tx_data,
+               tx_new => tx_new,
+               tx_done => tx_done
+       );
 end architecture top;
index cee42a30c341d2bdce30d1a3f02d2fd18be5ebd0..0afc7d4d89361c0acaaad6e4ba10b5d27987926d 100644 (file)
@@ -81,6 +81,7 @@ begin
                                                -- starbit (= '0')? dann kommen daten
                                                state_next <= DBITS;
                                                bitcnt_next <= 0;
+                                               baudcnt_next <= 0;
                                        else
                                                -- sonst war das nix...
                                                state_next <= IDLE;
@@ -91,7 +92,8 @@ begin
                                        baudcnt_next <= baudcnt_int + 1;
                                else
                                        baudcnt_next <= 0;
-                                       rx_data_next <= rx_data_int(6 downto 0) & rxd;
+                                       -- bitorder beachten
+                                       rx_data_next <= rxd & rx_data_int(7 downto 1);
 
                                        if bitcnt_int = 7 then
                                                state_next <= STOPBIT;