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

Subversion Repositories open_hitter

[/] [open_hitter/] [trunk/] [sim/] [rtl_sim/] [src/] [parse_price_sim.vhd] - Blame information for rev 10

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 stvhawes
--////////////////////////////////////////////////////////////////////
2
--//                                                              ////
3
--// parse_price_sim.vhd                                          ////
4
--//                                                              ////
5
--// This file is part of the open_hitter opencores effort.       ////
6
--// <http://www.opencores.org/cores/open_hitter/>                ////
7
--//                                                              ////
8
--// Module Description:                                          ////
9
--// Simulation program (synthesizable)                           ////
10
--// Unit test for parse_price.vhd                                ////
11
--//                                                              ////
12
--// To Do:                                                       ////
13
--//    #LOTS                                                     ////
14
--//                                                              ////
15
--// Author(s):                                                   ////
16
--// - Stephen Hawes                                              ////
17
--//                                                              ////
18
--////////////////////////////////////////////////////////////////////
19
--//                                                              ////
20
--// Copyright (C) 2015 Stephen Hawes and OPENCORES.ORG           ////
21
--//                                                              ////
22
--// This source file may be used and distributed without         ////
23
--// restriction provided that this copyright statement is not    ////
24
--// removed from the file and that any derivative work contains  ////
25
--// the original copyright notice and the associated disclaimer. ////
26
--//                                                              ////
27
--// This source file is free software; you can redistribute it   ////
28
--// and/or modify it under the terms of the GNU Lesser General   ////
29
--// Public License as published by the Free Software Foundation; ////
30
--// either version 2.1 of the License, or (at your option) any   ////
31
--// later version.                                               ////
32
--//                                                              ////
33
--// This source is distributed in the hope that it will be       ////
34
--// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
35
--// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
36
--// PURPOSE. See the GNU Lesser General Public License for more  ////
37
--// details.                                                     ////
38
--//                                                              ////
39
--// You should have received a copy of the GNU Lesser General    ////
40
--// Public License along with this source; if not, download it   ////
41
--// from <http://www.opencores.org/lgpl.shtml>                   ////
42
--//                                                              ////
43
--////////////////////////////////////////////////////////////////////
44
--//
45
--// \$Id\$  TAKE OUT THE \'s and this comment in order to get this to work
46
--//
47
--// CVS Revision History
48
--//
49
--// \$Log\$  TAKE OUT THE \'s and this comment in order to get this to work
50
--//
51
library ieee;
52
use ieee.std_logic_1164.all;
53
 
54
     entity parse_price_sim is
55
     port (
56
            RX_CLK: in std_logic;
57
            restart: in std_logic;
58
            processing: out std_logic;
59
            result_is_ok: out std_logic
60
     );
61
     end parse_price_sim;
62
 
63
     architecture behav of parse_price_sim is
64
        component parse_price
65
           port (
66
               RX_CLK: in std_logic;
67
               in_byte: in std_logic_vector(7 downto 0);
68
               byte_reset: in std_logic;
69
               byte_ready: in std_logic;
70
               price_ready: out std_logic;
71
               -- pxdata: out price_packet
72
                  px_type: out std_logic_vector(4 downto 0);
73
                  buy_sell: out std_logic_vector(2 downto 0);   -- 111 buy, 000 sell
74
                  px: out std_logic_vector(15 downto 0);     -- price
75
                  qty: out std_logic_vector(15 downto 0);    -- quantity
76
                  sec: out std_logic_vector(55 downto 0);    -- 7x 8bits securities identifier
77
                  id: out std_logic_vector(15 downto 0)     -- unique/identifier/counter
78
           );
79
        end component;
80
        --  Specifies which entity is bound with the component.
81
        for parse_price_0: parse_price use entity work.parse_price;
82
               signal in_byte: std_logic_vector(7 downto 0);
83
               signal byte_reset: std_logic;
84
               signal byte_ready: std_logic;
85
               signal price_ready: std_logic;
86
               -- pxdata: price_packet
87
                  signal px_type: std_logic_vector(4 downto 0);
88
                  signal buy_sell: std_logic_vector(2 downto 0);   -- 111 buy, 000 sell
89
                  signal px: std_logic_vector(15 downto 0);     -- price
90
                  signal qty: std_logic_vector(15 downto 0);    -- quantity
91
                  signal sec: std_logic_vector(55 downto 0);    -- 7x 8bits securities identifier
92
                  signal id: std_logic_vector(15 downto 0);     -- unique/identifier/counter
93
         signal pos: integer;
94
     begin
95
        --  Component instantiation.
96
        parse_price_0: parse_price port map (
97
               RX_CLK => RX_CLK,
98
               in_byte => in_byte,
99
               byte_reset => byte_reset,
100
               byte_ready => byte_ready,
101
               price_ready => price_ready,
102
               -- price_packet
103
                  px_type => px_type,
104
                  buy_sell => buy_sell,
105
                  px => px,
106
                  qty => qty,
107
                  sec => sec,
108
                  id => id
109
               );
110
        process (RX_CLK) is
111
           constant pkt : std_logic_vector(111 downto 0) := X"081234567857484154534543C078";
112
        begin
113
           if rising_edge(RX_CLK) then
114
              if (px_type = B"00001") and (buy_sell = B"000") and (px = B"00010010_00110100")  -- 081234
115
                 and (qty = B"01010110_01111000")                                              -- 5678
116
                 and (sec = B"01010111_01001000_01000001_01010100_01010011_01000101_01000011") -- 57484154534543
117
                 and (id  = B"11000000_01111000")                                              -- C078
118
              then
119
                 result_is_ok <= '1';
120
                 processing <= '0';
121
              else
122
                 result_is_ok <= '0';
123
              end if;
124
 
125
              if ((pos > -1) and (pos < 14)) then
126
                 in_byte <= pkt(8*pos+7 downto 8*pos);
127
                 byte_reset <= '0';
128
                 byte_ready <= '1';
129
              else
130
                 byte_ready <= '0';
131
              end if;
132
 
133
              if (pos > -1) then
134
                 pos <= pos -1;
135
              end if;
136
 
137
              if (restart = '1') then
138
                 byte_reset <= '1';
139
                 processing <= '1';
140
                 pos <= 15;
141
              end if;
142
 
143
            end if;
144
        end process;
145
 
146
 
147
     end behav;

powered by: WebSVN 2.1.0

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