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

Subversion Repositories ds1621

[/] [ds1621/] [trunk/] [files/] [tb_top.sv] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 akhachat
// Module:    top
2
// Revision:  01
3
// Language:  SystemVerilog
4
// Engineer:  Ashot Khachatryan
5
// Function:  Simulation top module for DS1621 behavioral model testing in Cadence IUS8.2 environment
6
// Comments:  20100402 AKH: Created.
7
//
8
 
9
`timescale 1ns / 1ps
10
 
11
module top;
12
 
13
int          cycle_count;
14
logic        RST;
15
logic  [2:0] I2C;      // WP for EEPROM, SCL, SDA
16
wire         SCL, SDA;
17
real         board_temp01, board_temp06;
18
wire         Temper_o01, Temper_o06;
19
wire  [64:1] Temper_s01 = $realtobits(board_temp01);
20
wire  [64:1] Temper_s06 = $realtobits(board_temp06);
21
bit          clk1k;
22
 
23
  // test vars
24
bit          bit_status;
25
logic  [7:0] data, g_logic_8;
26
logic [15:0] g_logic_16;
27
 
28
task  write( logic [1:0] W_DATA );  I2C  = W_DATA;  endtask  // {WP, SCL, SDA}
29
task  read( output bit data );      data = SDA;     endtask
30
 
31
assign WP  = I2C[2];
32
assign SCL = I2C[1];
33
assign SDA = I2C[0] ? 1'bz : 1'b0;
34
 
35
`include "ds1621/files/eeprom_macros.sv"   // EEPROM and DS1621 macro tasks
36
 
37
  // Simulation recording
38
initial begin
39
    $shm_open ("out.shm");
40
    $shm_probe("ACMTF");
41
end
42
 
43
initial begin
44
    cycle_count  = 1;
45
    I2C          = 3'b111;
46
    board_temp01 = 20.0;
47
    board_temp06 = 20.0;
48
   #1
49
    RST          = 1;
50
   #100
51
    RST          = 0;
52
    $display("*****************************");
53
    $display("*                           *");
54
    $display("*    DS1621 simulation      *");
55
    $display("*                           *");
56
    $display("*****************************");
57
 
58
    `include "ds1621/files/tb_ds1621.sv"
59
 
60
   #10_000
61
    $finish;
62
end
63
 
64
  // EEPROM
65
M24LC16B  u_24LC16B(
66
     .WP      ( WP )
67
    ,.SCL     ( SCL )
68
    ,.SDA     ( SDA )
69
    ,.RESET   ( RST )   // Model from Microchip
70
);
71
 
72
  // Temperature sensors // for simulation acceleration the timing is reduced here
73
DS1621_b  #(1000, 1_000_000, 500, 2_000_000) u_DS1621_b_01(
74
     .SCL     ( SCL )
75
    ,.SDA     ( SDA )
76
    ,.A0      ( 1'b1 )
77
    ,.A1      ( 1'b0 )
78
    ,.A2      ( 1'b0 )
79
    ,.TOUT    ( Temper_o01 )
80
    ,.TEMP_R  ( Temper_s01 )
81
);
82
 
83
DS1621_b  #(1000, 1_000_000, 500, 1_800_000) u_DS1621_b_06(
84
     .SCL     ( SCL )
85
    ,.SDA     ( SDA )
86
    ,.A0      ( 1'b0 )
87
    ,.A1      ( 1'b1 )
88
    ,.A2      ( 1'b1 )
89
    ,.TOUT    ( Temper_o06 )
90
    ,.TEMP_R  ( Temper_s06 )
91
);
92
 
93
initial begin  clk1k = 1; forever clk1k = #(1000/2) ~clk1k;  end
94
 
95
clocking cb1k @( posedge clk1k );
96
    default input #1step output #1step;
97
endclocking
98
 
99
// Cycle counter (cb1k)
100
always @( cb1k ) begin // posedge clk1k
101
    cycle_count <= cycle_count +1;
102
    if( !(cycle_count % 1000) )  $display("passing %0d us", cycle_count);
103
end
104
 
105
endmodule

powered by: WebSVN 2.1.0

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