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

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [rtl/] [gnsslib/] [rf3b/] [axi_recorder.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 sergeykhbr
-----------------------------------------------------------------------------
2
--! @file
3
--! @copyright Copyright 2017 GNSS Sensor Ltd. All right reserved.
4
--! @author    Sergey Khabarov - sergeykhbr@gmail.com
5
--! @brief     ADC samples recorder.
6
-----------------------------------------------------------------------------
7
library ieee;
8
use ieee.std_logic_1164.all;
9
 
10
library commonlib;
11
use commonlib.types_common.all;
12
 
13
--! AMBA system bus specific library
14
library ambalib;
15
--! AXI4 configuration constants.
16
use ambalib.types_amba4.all;
17
library techmap;
18
use techmap.types_mem.all;
19
 
20
entity axi_recorder is
21
  generic (
22
    tech     : integer := 0;
23
    xaddr    : integer := 0;
24
    xmask    : integer := 16#ffff0#
25
  );
26
  port (
27
    nrst    : in  std_logic;
28
    clk_bus : in  std_logic;
29
    clk_adc : in  std_logic;
30
    o_cfg   : out nasti_slave_config_type;
31
    i_axi   : in  nasti_slave_in_type;
32
    o_axi   : out nasti_slave_out_type;
33
    i_gps_I : in std_logic_vector(1 downto 0);
34
    i_gps_Q : in std_logic_vector(1 downto 0)
35
  );
36
end;
37
 
38
architecture rtl of axi_recorder is
39
 
40
  constant xconfig : nasti_slave_config_type := (
41
     descrtype => PNP_CFG_TYPE_SLAVE,
42
     descrsize => PNP_CFG_SLAVE_DESCR_BYTES,
43
     irq_idx => 0,
44
     xaddr => conv_std_logic_vector(xaddr, CFG_NASTI_CFG_ADDR_BITS),
45
     xmask => conv_std_logic_vector(xmask, CFG_NASTI_CFG_ADDR_BITS),
46
     vid => VENDOR_GNSSSENSOR,
47
     did => GNSSSENSOR_ADC_RECORDER
48
  );
49
 
50
  type registers is record
51
    bank_axi : nasti_slave_bank_type;
52
    state : std_logic;
53
  end record;
54
 
55
  type adc_registers is record
56
      shifter : std_logic_vector(63 downto 0);
57
      sample_cnt : std_logic_vector(16 downto 0);
58
      waddr  : std_logic_vector(12 downto 0);
59
      we : std_logic;
60
      state : std_logic;
61
  end record;
62
 
63
  signal r, rin : registers;
64
  signal r2 : adc_registers;
65
  signal wb_ram_raddr : std_logic_vector(12 downto 0);
66
  signal wb_ram_rdata : std_logic_vector(63 downto 0);
67
 
68
begin
69
 
70
   ram2p : syncram_2p_tech generic map (
71
        tech => tech,
72
        abits => 13,
73
        dbits => 64,
74
        sepclk => 1
75
   ) port map (
76
        rclk     => clk_bus,
77
        renable  => '1',
78
        raddress => wb_ram_raddr,
79
        dataout  => wb_ram_rdata,
80
        wclk     => clk_adc,
81
        write    => r2.we,
82
        waddress => r2.waddr,
83
        datain   => r2.shifter
84
   );
85
 
86
  adcproc0 : process(clk_adc) begin
87
    if rising_edge(clk_adc) then
88
        if nrst = '0' then
89
            r2.shifter <= (others => '0');
90
            r2.sample_cnt <= (others => '0');
91
            r2.waddr <= (others => '0');
92
            r2.we <= '0';
93
            r2.state <= '0';
94
        elsif r2.state = '1' then
95
            r2.shifter <= r2.shifter(59 downto 0) & i_gps_I & i_gps_Q;
96
            r2.sample_cnt <= r2.sample_cnt + 1;
97
 
98
            r2.waddr <= r2.sample_cnt(16 downto 4);
99
            r2.we <= '0';
100
            if r2.sample_cnt(3 downto 0) = "1111" then
101
               r2.we <= '1';
102
            end if;
103
            if r2.sample_cnt = (X"FFFF"&'1') then
104
               r2.state <= '0';
105
            end if;
106
        else
107
            r2.we <= '0';
108
            r2.shifter <= (others => '0');
109
            r2.sample_cnt <= (others => '0');
110
            r2.state <= r.state;
111
        end if;
112
    end if;
113
  end process;
114
 
115
 
116
 
117
  comblogic : process(nrst, r, r2.state, i_axi, wb_ram_rdata)
118
    variable v : registers;
119
    variable rdata : std_logic_vector(CFG_NASTI_DATA_BITS-1 downto 0);
120
  begin
121
 
122
    v := r;
123
    procedureAxi4(i_axi, xconfig, r.bank_axi, v.bank_axi);
124
 
125
    wb_ram_raddr <= r.bank_axi.raddr(0)(15 downto 3);
126
 
127
    if r.bank_axi.raddr(0)(2) = '0' then
128
      rdata := wb_ram_rdata;
129
    else
130
      rdata := wb_ram_rdata(63 downto 32) & wb_ram_rdata(63 downto 32);
131
    end if;
132
 
133
    if r2.state = '1' then
134
        v.state := '0';
135
    end if;
136
 
137
    -- write registers
138
    if i_axi.w_valid = '1' and
139
       r.bank_axi.wstate = wtrans and
140
       r.bank_axi.wresp = NASTI_RESP_OKAY then
141
 
142
            v.state := '1';
143
    end if;
144
    -- reset operation
145
 
146
    if nrst = '0' then
147
      v.bank_axi := NASTI_SLAVE_BANK_RESET;
148
      v.state := '0';
149
    end if;
150
 
151
    o_axi <= functionAxi4Output(r.bank_axi, rdata);
152
    rin <= v;
153
  end process;
154
 
155
 
156
  o_cfg <= xconfig;
157
 
158
  -- registers:
159
  regs : process(clk_bus) begin
160
    if rising_edge(clk_bus) then
161
       r <= rin;
162
    end if;
163
  end process;
164
 
165
end;

powered by: WebSVN 2.1.0

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