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

Subversion Repositories openrisc

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

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
// File Name                      : bin2c.c
10
// 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
// 0 : wb_dat_o <= #1 32'h18000000;
48
// 1 : wb_dat_o <= #1 32'h18200000;
49
// 2 : wb_dat_o <= #1 32'h1880b000;
50
// 3 : wb_dat_o <= #1 32'ha8400051;
51
// 4 : wb_dat_o <= #1 32'hd8041000;
52
// 5 : wb_dat_o <= #1 32'h18c00000;
53
// 6 : wb_dat_o <= #1 32'h18e00000;
54
//
55
// etc...
56
//
57
//
58
 
59
#include <stdio.h>
60
#include <stdint.h>
61
 
62
#define OUT_REG_STRING "wb_dat_o"
63
//#define ASSIGN_STRING "<= #1"
64
#define ASSIGN_STRING "<= "
65
#define SIZE_STRING "32'h"
66
#define BEFORE_STRING "%d : "OUT_REG_STRING" "ASSIGN_STRING" "SIZE_STRING
67
 
68
//#define BEFORE_STRING "%d : wb_dat_o <= 32'h"
69
 
70
 
71
int main(void)
72
{
73
 
74
  int c, word_counter=0;
75
  uint32_t word;
76
  uint8_t *wordarray = (uint8_t*) &word;
77
 
78
  while((c = getchar()) != EOF) {
79
    /* Endianess might change things here */
80
    wordarray[3] = c;
81
    wordarray[2] = getchar();
82
    wordarray[1] = getchar();
83
    wordarray[0] = getchar();
84
    printf(BEFORE_STRING, word_counter);
85
    printf("%.8x;\n", word);
86
    word_counter++;
87
  }
88
 
89
  return(0);
90
 
91
}

powered by: WebSVN 2.1.0

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