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

Subversion Repositories pdp1

[/] [pdp1/] [trunk/] [rtl/] [vhdl/] [testtop.vhd] - Diff between revs 3 and 10

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 3 Rev 10
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Company: 
-- Company: 
-- Engineer:
-- Engineer:
--
--
-- Create Date:   00:00:04 08/14/2009
-- Create Date:   00:00:04 08/14/2009
-- Design Name:   
-- Design Name:   
-- Module Name:   /home/yann/fpga/work/pdp1-3/testtop.vhd
-- Module Name:   /home/yann/fpga/work/pdp1-3/testtop.vhd
-- Project Name:  pdp1-3
-- Project Name:  pdp1-3
-- Target Device:  
-- Target Device:  
-- Tool versions:  
-- Tool versions:  
-- Description:   
-- Description:   
-- 
-- 
-- VHDL Test Bench Created by ISE for module: top
-- VHDL Test Bench Created by ISE for module: top
-- 
-- 
-- Dependencies:
-- Dependencies:
-- 
-- 
-- Revision:
-- Revision:
-- Revision 0.01 - File Created
-- Revision 0.01 - File Created
-- Additional Comments:
-- Additional Comments:
--
--
-- Notes: 
-- Notes: 
-- This testbench has been automatically generated using types std_logic and
-- This testbench has been automatically generated using types std_logic and
-- std_logic_vector for the ports of the unit under test.  Xilinx recommends
-- std_logic_vector for the ports of the unit under test.  Xilinx recommends
-- that these types always be used for the top-level I/O of a design in order
-- that these types always be used for the top-level I/O of a design in order
-- to guarantee that the testbench will bind correctly to the post-implementation 
-- to guarantee that the testbench will bind correctly to the post-implementation 
-- simulation model.
-- simulation model.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
LIBRARY ieee;
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.all;
 
USE ieee.numeric_std.ALL;
USE ieee.numeric_std.ALL;
 
 
 
--USE ieee.textio.ALL;
 
 
ENTITY testtop IS
ENTITY testtop IS
END testtop;
END testtop;
 
 
ARCHITECTURE behavior OF testtop IS
ARCHITECTURE behavior OF testtop IS
 
 
    -- Component Declaration for the Unit Under Test (UUT)
    -- Component Declaration for the Unit Under Test (UUT)
 
 
    COMPONENT top
    COMPONENT top
    PORT(
    PORT(
         CLK_50M : IN  std_logic;
         CLK_50M : IN  std_logic;
 
         CLK_AUX : IN  std_logic;
         LED : OUT  std_logic_vector(7 downto 0);
         LED : OUT  std_logic_vector(7 downto 0);
         SW : IN  std_logic_vector(3 downto 0);
         SW : IN  std_logic_vector(3 downto 0);
         AWAKE : OUT  std_logic;
         AWAKE : OUT  std_logic;
         SPI_MOSI : OUT  std_logic;
         SPI_MOSI : OUT  std_logic;
         DAC_CS : OUT  std_logic;
         DAC_CS : OUT  std_logic;
         SPI_SCK : OUT  std_logic;
         SPI_SCK : OUT  std_logic;
         DAC_CLR : OUT  std_logic;
         DAC_CLR : OUT  std_logic;
         DAC_OUT : IN  std_logic;
         DAC_OUT : IN  std_logic;
                        RS232_DCE_RXD : IN std_logic;
                        RS232_DCE_RXD : IN std_logic;
                        RS232_DCE_TXD : OUT std_logic
                        RS232_DCE_TXD : OUT std_logic
        );
        );
    END COMPONENT;
    END COMPONENT;
 
 
 
 
   --Inputs
   --Inputs
   signal CLK_50M : std_logic := '0';
   signal CLK_50M : std_logic := '0';
 
   signal CLK_AUX : std_logic := '0';
   signal SW : std_logic_vector(3 downto 0) := (others => '0');
   signal SW : std_logic_vector(3 downto 0) := (others => '0');
   signal DAC_OUT : std_logic := '0';
   signal DAC_OUT : std_logic := '0';
 
 
        --Outputs
        --Outputs
   signal LED : std_logic_vector(7 downto 0);
   signal LED : std_logic_vector(7 downto 0);
   signal AWAKE : std_logic;
   signal AWAKE : std_logic;
   signal SPI_MOSI : std_logic;
   signal SPI_MOSI : std_logic;
   signal DAC_CS : std_logic;
   signal DAC_CS : std_logic;
   signal SPI_SCK : std_logic;
   signal SPI_SCK : std_logic;
   signal DAC_CLR : std_logic;
   signal DAC_CLR : std_logic;
        signal TXD, RXD : std_logic;
        signal TXD, RXD : std_logic;
 
 
 
        -- UART interface
 
        COMPONENT Minimal_UART_CORE
 
        PORT(
 
                CLOCK : IN std_logic;
 
                RXD : IN std_logic;
 
                INP : IN std_logic_vector(7 downto 0);
 
                WR : IN std_logic;
 
                OUTP : INOUT std_logic_vector(7 downto 0);
 
                EOC : OUT std_logic;
 
                TXD : OUT std_logic;
 
                EOT : OUT std_logic;
 
                READY : OUT std_logic
 
                );
 
        END COMPONENT;
 
        signal received_byte, old_received_byte, tx_ready, wrote, byte_request,
 
                eot : std_logic := '0';
 
        signal read_byte, write_byte: std_logic_vector(7 downto 0);
 
 
 
 
   constant CLK_50M_period : time := 20ns;
   constant CLK_50M_period : time := 20ns;
 
   constant CLK_AUX_period : time := 7.5ns;
 
 
        constant bittime : time := 8.680555us; --1s/115200;
        constant bittime : time := 8.680555us; --1s/115200;
 
        constant waittime : time := 20*bittime;
 
 
 
   procedure send_byte (bytetosend : in std_logic_vector(7 downto 0);
 
                                                                signal tx_ready : in std_logic;
 
                                                                signal eot : in std_logic;
 
                                                                signal write_byte : out std_logic_vector(7 downto 0);
 
                                                                signal wrote : out std_logic)
 
        is
 
      -- subprogram_declarative_items (constant declarations, variable declarations, etc.)
 
   begin
 
--              wait for 100ns;
 
                wait until rising_edge(CLK_50M) and tx_ready = '1' and eot='0';
 
                write_byte <= bytetosend;
 
                wrote <= '1';
 
                wait until rising_edge(CLK_50M);
 
                wrote <= '0';
 
--              wait until eot='0' and tx_ready='1';
 
 
 
                -- Without UART, it was something like:
 
--              RXD <= '0'; wait for bittime;
 
--              RXD <= bytetosend(0); wait for bittime;
 
--              RXD <= bytetosend(1); wait for bittime;
 
--              RXD <= bytetosend(2); wait for bittime;
 
--              RXD <= bytetosend(3); wait for bittime;
 
--              RXD <= bytetosend(4); wait for bittime;
 
--              RXD <= bytetosend(5); wait for bittime;
 
--              RXD <= bytetosend(6); wait for bittime;
 
--              RXD <= bytetosend(7); wait for bittime;
 
--              RXD <= '1'; wait for bittime;           -- first sixbit 000101
 
--              wait for waittime;
 
   end send_byte;
 
 
 
 
BEGIN
BEGIN
 
 
        -- Instantiate the Unit Under Test (UUT)
        -- Instantiate the Unit Under Test (UUT)
   uut: top PORT MAP (
   uut: top PORT MAP (
          CLK_50M => CLK_50M,
          CLK_50M => CLK_50M,
 
                         CLK_AUX => CLK_AUX,
          LED => LED,
          LED => LED,
          SW => SW,
          SW => SW,
          AWAKE => AWAKE,
          AWAKE => AWAKE,
          SPI_MOSI => SPI_MOSI,
          SPI_MOSI => SPI_MOSI,
          DAC_CS => DAC_CS,
          DAC_CS => DAC_CS,
          SPI_SCK => SPI_SCK,
          SPI_SCK => SPI_SCK,
          DAC_CLR => DAC_CLR,
          DAC_CLR => DAC_CLR,
          DAC_OUT => DAC_OUT,
          DAC_OUT => DAC_OUT,
                        RS232_DCE_RXD => RXD,
                        RS232_DCE_RXD => RXD,
                        RS232_DCE_TXD => TXD
                        RS232_DCE_TXD => TXD
        );
        );
 
 
   -- No clocks detected in port list. Replace CLK_50M below with 
   -- No clocks detected in port list. Replace CLK_50M below with 
   -- appropriate port name 
   -- appropriate port name 
 
 
   CLK_50M_process :process
   CLK_50M_process :process
   begin
   begin
                CLK_50M <= '0';
                CLK_50M <= '0';
                wait for CLK_50M_period/2;
                wait for CLK_50M_period/2;
                CLK_50M <= '1';
                CLK_50M <= '1';
                wait for CLK_50M_period/2;
                wait for CLK_50M_period/2;
   end process;
   end process;
 
 
 
   CLK_AUX_process :process
 
   begin
 
                CLK_AUX <= '0';
 
                wait for CLK_AUX_period/2;
 
                CLK_AUX <= '1';
 
                wait for CLK_AUX_period/2;
 
   end process;
 
 
 
        -- UART for talking to UUT
 
        Inst_Minimal_UART_CORE: Minimal_UART_CORE PORT MAP(
 
                CLOCK => CLK_50M,
 
 
 
                EOC => received_byte,   -- end of character; rising edge indicates valid data in OUTP
 
                OUTP => read_byte,
 
 
 
                RXD => TXD,
 
                TXD => RXD,
 
 
 
                EOT => eot,     -- end of transmit; indicates a character has been sent
 
                INP => write_byte,
 
                READY => tx_ready,      -- indicates that we may write
 
                WR => wrote
 
        );
 
 
   -- Stimulus process
   -- Stimulus process
   stim_proc: process
   stim_proc: process
   begin
   begin
                RXD <= '1';
                wait for 1ms;
      -- hold reset state for 100ms.
                send_byte("10000101", tx_ready, eot, write_byte, wrote);
      wait for 10ms;
                send_byte("00111111", tx_ready, eot, write_byte, wrote);  -- ignored, as bit 7 is not set
 
                send_byte("10000110", tx_ready, eot, write_byte, wrote);
                                wait for 16*bittime;
                send_byte("10111000", tx_ready, eot, write_byte, wrote);  -- Together 050670
                -- TODO: show reply data
                -- TODO: show reply data
                RXD <= '0'; wait for bittime;
 
                RXD <= '1'; wait for bittime;
 
                RXD <= '0'; wait for bittime;
 
                RXD <= '1'; wait for bittime;
 
                RXD <= '0'; wait for bittime;
 
                RXD <= '0'; wait for bittime;
 
                RXD <= '0'; wait for bittime;
 
                RXD <= '0'; wait for bittime;
 
                RXD <= '1'; wait for bittime;
 
                RXD <= '1'; wait for bittime;           -- first sixbit 000101
 
                wait for 16*bittime;
 
                RXD <= '0'; wait for bittime;
 
                RXD <= '1'; wait for bittime;
 
                RXD <= '1'; wait for bittime;
 
                RXD <= '1'; wait for bittime;
 
                RXD <= '1'; wait for bittime;
 
                RXD <= '1'; wait for bittime;
 
                RXD <= '1'; wait for bittime;
 
                RXD <= '0'; wait for bittime;
 
                RXD <= '0'; wait for bittime;
 
                RXD <= '1'; wait for bittime;                           -- this byte is not marked as binary data and should be skipped
 
                wait for 16*bittime;
 
                RXD <= '0'; wait for bittime;
 
                RXD <= '0'; wait for bittime;
 
                RXD <= '1'; wait for bittime;
 
                RXD <= '1'; wait for bittime;
 
                RXD <= '0'; wait for bittime;
 
                RXD <= '0'; wait for bittime;
 
                RXD <= '0'; wait for bittime;
 
                RXD <= '0'; wait for bittime;
 
                RXD <= '1'; wait for bittime;
 
                RXD <= '1'; wait for bittime;           -- second sixbit 001100
 
                wait for 16*bittime;
 
                RXD <= '0'; wait for bittime;
 
                RXD <= '0'; wait for bittime;
 
                RXD <= '0'; wait for bittime;
 
                RXD <= '0'; wait for bittime;
 
                RXD <= '1'; wait for bittime;
 
                RXD <= '1'; wait for bittime;
 
                RXD <= '1'; wait for bittime;
 
                RXD <= '0'; wait for bittime;
 
                RXD <= '1'; wait for bittime;
 
                RXD <= '1'; wait for bittime;           -- third sixbit 111000
 
 
 
 
 
      wait for CLK_50M_period*10;
      wait for CLK_50M_period*10;
 
 
      -- insert stimulus here 
      -- insert stimulus here 
 
 
      wait;
      wait;
   end process;
   end process;
 
 
END;
END;
 
 

powered by: WebSVN 2.1.0

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