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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [utils/] [bin2vlogarray.c] - Blame information for rev 382

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

Line No. Rev Author Line
1 349 julius
/*$$HEADER*/
2
/******************************************************************************/
3
/*                                                                            */
4
/*                    H E A D E R   I N F O R M A T I O N                     */
5
/*                                                                            */
6
/******************************************************************************/
7
 
8
// Project Name                   : ORPSoC v2
9 361 julius
// File Name                      : bin2vlogarray.c
10 349 julius
// Prepared By                    : 
11
// Project Start                  : 
12
 
13
/*$$COPYRIGHT NOTICE*/
14
/******************************************************************************/
15
/*                                                                            */
16
/*                      C O P Y R I G H T   N O T I C E                       */
17
/*                                                                            */
18
/******************************************************************************/
19
/*
20
  This library is free software; you can redistribute it and/or
21
  modify it under the terms of the GNU Lesser General Public
22
  License as published by the Free Software Foundation;
23
  version 2.1 of the License, a copy of which is available from
24
  http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt.
25
 
26
  This library is distributed in the hope that it will be useful,
27
  but WITHOUT ANY WARRANTY; without even the implied warranty of
28
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
29
  Lesser General Public License for more details.
30
 
31
  You should have received a copy of the GNU Lesser General Public
32
  License along with this library; if not, write to the Free Software
33
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
34
*/
35
 
36
/*$$DESCRIPTION*/
37
/******************************************************************************/
38
/*                                                                            */
39
/*                           D E S C R I P T I O N                            */
40
/*                                                                            */
41
/******************************************************************************/
42
//
43
// Generate verilog lines assigning array output from binary final input
44
//
45
// Looks like this:
46
//
47 361 julius
// 0 : wb_dat_o <= 32'h18000000;
48
// 1 : wb_dat_o <= 32'h18200000;
49
// 2 : wb_dat_o <= 32'h1880b000;
50
// 3 : wb_dat_o <= 32'ha8400051;
51
// 4 : wb_dat_o <= 32'hd8041000;
52
// 5 : wb_dat_o <= 32'h18c00000;
53
// 6 : wb_dat_o <= 32'h18e00000;
54 349 julius
//
55
// etc...
56
//
57 361 julius
// The generated file is pulled into the appropriate part of a verilog 
58
// module and gets synthesized.
59 349 julius
 
60
#include <stdio.h>
61
#include <stdint.h>
62
 
63
#define OUT_REG_STRING "wb_dat_o"
64 361 julius
 
65
// OR1200 no longer has these #delays on synchronous assigns - so we don't need
66
// them here anymore either.
67 349 julius
//#define ASSIGN_STRING "<= #1"
68
#define ASSIGN_STRING "<= "
69 361 julius
 
70 349 julius
#define SIZE_STRING "32'h"
71 361 julius
 
72
// Concatenate the defines 
73 349 julius
#define BEFORE_STRING "%d : "OUT_REG_STRING" "ASSIGN_STRING" "SIZE_STRING
74
 
75
//#define BEFORE_STRING "%d : wb_dat_o <= 32'h"
76
 
77
 
78
int main(void)
79
{
80
 
81
  int c, word_counter=0;
82
  uint32_t word;
83
  uint8_t *wordarray = (uint8_t*) &word;
84
 
85
  while((c = getchar()) != EOF) {
86
    /* Endianess might change things here */
87
    wordarray[3] = c;
88
    wordarray[2] = getchar();
89
    wordarray[1] = getchar();
90
    wordarray[0] = getchar();
91
    printf(BEFORE_STRING, word_counter);
92
    printf("%.8x;\n", word);
93
    word_counter++;
94
  }
95
 
96
  return(0);
97
 
98
}

powered by: WebSVN 2.1.0

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