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

Subversion Repositories test_project

[/] [test_project/] [trunk/] [bench/] [sysc/] [src/] [OrpsocMain.cpp] - Blame information for rev 51

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 44 julius
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  ORPSoC SystemC Testbench                                    ////
4
////                                                              ////
5
////  Description                                                 ////
6
////  ORPSoC Testbench file                                       ////
7
////                                                              ////
8
////  To Do:                                                      ////
9
////                                                              ////
10
////                                                              ////
11
////  Author(s):                                                  ////
12
////      - Jeremy Bennett jeremy.bennett@embecosm.com            ////
13
////      - Julius Baxter jb@orsoc.se                             ////
14
////                                                              ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18
//// Copyright (C) 2009 Authors and OPENCORES.ORG                 ////
19
////                                                              ////
20
//// This source file may be used and distributed without         ////
21
//// restriction provided that this copyright statement is not    ////
22
//// removed from the file and that any derivative work contains  ////
23
//// the original copyright notice and the associated disclaimer. ////
24
////                                                              ////
25
//// This source file is free software; you can redistribute it   ////
26
//// and/or modify it under the terms of the GNU Lesser General   ////
27
//// Public License as published by the Free Software Foundation; ////
28
//// either version 2.1 of the License, or (at your option) any   ////
29
//// later version.                                               ////
30
////                                                              ////
31
//// This source is distributed in the hope that it will be       ////
32
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
33
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
34
//// PURPOSE.  See the GNU Lesser General Public License for more ////
35
//// details.                                                     ////
36
////                                                              ////
37
//// You should have received a copy of the GNU Lesser General    ////
38
//// Public License along with this source; if not, download it   ////
39
//// from http://www.opencores.org/lgpl.shtml                     ////
40
////                                                              ////
41
//////////////////////////////////////////////////////////////////////
42
 
43
#include "OrpsocMain.h"
44
 
45
#include "Vorpsoc_top.h"
46 48 julius
#include "OrpsocAccess.h"
47 50 julius
#include "TraceSC.h"
48 48 julius
#include "ResetSC.h"
49
#include "Or1200MonitorSC.h"
50 51 julius
#include "UartSC.h"
51 44 julius
 
52
 
53
int sc_main (int   argc,
54
             char *argv[] )
55
{
56
  // CPU clock (also used as JTAG TCK) and reset (both active high and low)
57
  sc_time  clkPeriod (BENCH_CLK_HALFPERIOD * 2.0, TIMESCALE_UNIT);
58
 
59
  sc_clock             clk ("clk", clkPeriod);
60
  sc_signal<bool>      rst;
61
  sc_signal<bool>      rstn;
62 47 julius
  sc_signal<bool>      rst_o;
63 44 julius
 
64
  sc_signal<bool>      jtag_tdi;                // JTAG interface
65
  sc_signal<bool>      jtag_tdo;
66
  sc_signal<bool>      jtag_tms;
67
  sc_signal<bool>      jtag_trst;
68
 
69
  sc_signal<bool>      uart_rx;         // External UART
70
  sc_signal<bool>      uart_tx;
71
 
72 47 julius
  sc_signal<bool> spi_sd_sclk; // SD Card Memory SPI
73
  sc_signal<bool> spi_sd_ss;
74
  sc_signal<bool> spi_sd_miso;
75
  sc_signal<bool> spi_sd_mosi;
76
 
77
  sc_signal<uint32_t> gpio_a; // GPIO bus - output only in verilator sims
78
 
79
  sc_signal<bool> spi1_mosi;
80
  sc_signal<bool> spi1_miso;
81
  sc_signal<bool> spi1_ss;
82
  sc_signal<bool> spi1_sclk;
83
 
84
 
85 44 julius
  // Verilator accessor
86 48 julius
  OrpsocAccess    *accessor;
87 44 julius
 
88
  // Modules
89
  Vorpsoc_top *orpsoc;          // Verilated ORPSoC
90 50 julius
  TraceSC          *trace;              // Drive VCD
91 51 julius
 
92 48 julius
  ResetSC          *reset;              // Generate a RESET signal
93
  Or1200MonitorSC  *monitor;            // Handle l.nop x instructions
94 51 julius
  UartSC          *uart;                // Handle UART signals
95 44 julius
 
96
  // Instantiate the Verilator model, VCD trace handler and accessor
97
  orpsoc     = new Vorpsoc_top ("orpsoc");
98 50 julius
  trace      = new TraceSC ("trace", orpsoc, "v-dump.vcd");
99 48 julius
  accessor   = new OrpsocAccess (orpsoc);
100 51 julius
 
101 44 julius
  // Instantiate the SystemC modules
102 48 julius
  reset         = new ResetSC ("reset", BENCH_RESET_TIME);
103
  monitor       = new Or1200MonitorSC ("monitor", accessor);
104 51 julius
  uart          = new UartSC("uart"); // TODO: Probalby some sort of param
105 44 julius
 
106
  // Connect up ORPSoC
107
  orpsoc->clk_pad_i (clk);
108
  orpsoc->rst_pad_i (rstn);
109 47 julius
  orpsoc->rst_pad_o (rst_o);
110 44 julius
 
111
  orpsoc->dbg_tck_pad_i  (clk);         // JTAG interface
112
  orpsoc->dbg_tdi_pad_i  (jtag_tdi);
113
  orpsoc->dbg_tms_pad_i  (jtag_tms);
114 47 julius
  orpsoc->dbg_tdo_pad_o  (jtag_tdo);
115 44 julius
 
116
  orpsoc->uart0_srx_pad_i (uart_rx);            // External UART
117
  orpsoc->uart0_stx_pad_o (uart_tx);
118
 
119 47 julius
  orpsoc->spi_sd_sclk_pad_o (spi_sd_sclk); // SD Card Memory SPI
120
  orpsoc->spi_sd_ss_pad_o (spi_sd_ss);
121
  orpsoc->spi_sd_miso_pad_i (spi_sd_miso);
122
  orpsoc->spi_sd_mosi_pad_o (spi_sd_mosi);
123
 
124
  orpsoc->spi1_mosi_pad_o (spi1_mosi);
125
  orpsoc->spi1_miso_pad_i (spi1_miso);
126
  orpsoc->spi1_ss_pad_o  (spi1_ss);
127
  orpsoc->spi1_sclk_pad_o (spi1_sclk);
128
 
129
 
130
  orpsoc->gpio_a_pad_io (gpio_a); // GPIO bus - output only in 
131
                                  // verilator sims
132
 
133
 
134 44 julius
  // Connect up the VCD trace handler
135 50 julius
  trace->clk (clk);                     // Trace
136 44 julius
 
137
  // Connect up the SystemC  modules
138 48 julius
  reset->clk (clk);                     // Reset
139
  reset->rst (rst);
140
  reset->rstn (rstn);
141 44 julius
 
142 48 julius
  monitor->clk (clk);                   // Monitor
143 44 julius
 
144 51 julius
  uart->clk (clk); // Uart
145
  uart->uartrx (uart_rx); // orpsoc's receive line
146
  uart->uarttx (uart_tx); // orpsoc's transmit line
147 44 julius
 
148 51 julius
   // Tie off signals
149
   jtag_tdi      = 1;                   // Tie off the JTAG inputs
150
   jtag_tms      = 1;
151 44 julius
 
152 51 julius
   spi_sd_miso = 0; // Tie off master-in/slave-out of SD SPI bus
153 47 julius
 
154
  spi1_miso = 0;
155
 
156
  printf("Beginning test\n");
157
 
158 51 julius
  // Init the UART function
159
  uart->initUart(10000000, 115200);
160
 
161 44 julius
  // Execute until we stop
162
  sc_start ();
163
 
164
  // Free memory
165 48 julius
  delete monitor;
166
  delete reset;
167 44 julius
 
168 48 julius
  delete accessor;
169 44 julius
 
170 50 julius
  delete trace;
171 44 julius
  delete orpsoc;
172
 
173
  return 0;
174
 
175
}       /* sc_main() */

powered by: WebSVN 2.1.0

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